I have the following code that works:
ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); jsEngine.eval("some script"); jsEngine.invokeMethod(jsEngine.eval("foo"), "bar");
but I want to use a precompiled script, so I donβt need to evaluate the script every time I need to run it, so I try;
ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); CompiledScript compiledJS = jsEngine.compile("some script");
but then I'm not sure what to do with CompiledScript, how do I call a method? it does not implement anything other than eval (), apparently: https://docs.oracle.com/javase/8/docs/api/javax/script/CompiledScript.html
source share