due to Nashorn being discontinued we are currently trying to change our (still Java 8) application (very big monolith) from Nashorn to GraalVM. Due to the application being used as library in multiple projects, instead of using the whole GraalVM runtime we decided to just adding the necessary jars to the class path (which seem to work so far).
To use GraalVM, I changed all occurrences of getEngineByName to graal.js as follow:
ScriptEngineManager sem = new ScriptEngineManager(null); scriptEngine = sem.getEngineByName("graal.js");
What would be the best approach to achieve this?
you can compare the class name of the script engine with com.oracle.truffle.js.scriptengine.GraalJSScriptEngine something like this:
ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("graal.js"); String engineName = scriptEngine.getClass().getName(); boolean isGraalJS = engineName.equals("com.oracle.truffle.js.scriptengine.GraalJSScriptEngine"); System.out.println(isGraalJS);