How do you invoke a method in a Nashorn CompiledScript?
问题 I have the following code which works: ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); jsEngine.eval("some script"); jsEngine.invokeMethod(jsEngine.eval("foo"), "bar"); but I want to do use a pre-compiled script so I don't have to evaluate the script every time I need to run it, so I'm trying; ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); CompiledScript compiledJS = jsEngine.compile("some script"); but then I'm not sure what to do