java-json-tools/json-schema-core

Add support for GraalJS script engine as possible replacement for the deprecated Nashorn

sdoeringNew opened this issue · 1 comments

With Java 15 Nashorn was finally removed from the JDK. But with GraalJS there is some sort of replacement.

If the application runs with the polyglot GraalVM there is out of the box support for GraalJS.
Or GraalJS and its ScriptEngine could be simply added as dependency and ran with the JDK.

But there is one caveat.

JavaScript is single threaded. Rhino and Nashorn haven't cared but GraalJS does. Multi-threaded access to the same context will result in an exception.

See: https://www.graalvm.org/reference-manual/js/Multithreading/

One of the recommendations is proper synchronization. And I think I'll go with that. A synchronized access to the GraalJS script engine shall still be faster than multi-threaded Rhino. GraalJS is magnitudes faster than Rhino.