Hi there,
I've built a small case where I evaluate a compiled script equipped with a
custom bindings.
The script is equipped with some variables and and compiled like this:
engine.put("shopId", "test");
runner = (Bindings)
engine.compile(ad.getCondition_script().getCode()).eval();
afterwards, I execute the "run" method on the object returned by eval() like
this:
return (MyCustomObject) engine.invokeMethod(runner, "run", attr);
the run method does local compilations but does not change anything so
basically the runner is immutable.
I access it from various threads.
When profiling the code I see a lot of time spent in
java.security.AccessController.doPrivileged() which is invoked in
setNashornGlobal() if the globals changed.
I'm a bit unsure what changed globals really mean because in my case nothing
(either context nor bindings) changed and I wonder if it is necessary.
Best,
Tobias