I am using Nashorn via JSR 223 to execute small snippets of user entered script:
public Invocable buildInvocable(String script) throws ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName(ENGINE);
engine.eval(functions);
engine.eval(script);
return (Invocable) engine;
}
The varying user script calls JavaScript functions that are defined in a static, central library (held in the functions
String in the code snippet above).
Every time I want to get hold of an Invocable
that I can call from my Java I am constantly having to recompile the large library code.
Is there any way to join a previously compiled piece of code in with new code?