-
Bug
-
Resolution: Fixed
-
P3
-
8u60, 9
-
None
-
b68
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085675 | emb-9 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | team |
JDK-8129192 | 8u65 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b02 |
JDK-8081673 | 8u60 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b20 |
JDK-8138549 | emb-8u65 | Unassigned | P3 | Resolved | Fixed | b02 |
JDK-8129717 | emb-8u60 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b20 |
import javax.script.*;
import jdk.nashorn.api.scripting.*;
public class Main {
ScriptEngineFactory factory = new NashornScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
Bindings globalBindings = new SimpleBindings();
Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
ScriptContext context = new SimpleScriptContext();
public static void main(String[] ar) throws Exception {
Main main = new Main();
main.context.setBindings(main.globalBindings, ScriptContext.GLOBAL_SCOPE);
main.context.setBindings(main.engineBindings, ScriptContext.ENGINE_SCOPE);
main.engineBindings.put("program", main);
main.globalBindings.put("text", "initial text");
main.engine.eval(
" print(text); " +
" program.someMethod(); " +
" print(text);", main.context);
/* Expected output:
initial text
another text
initial text
Output seen:
initial text
another text
another text
*/
}
public void someMethod() throws Exception {
// a context with a new global bindings, same engine bindings
ScriptContext context = new SimpleScriptContext();
Bindings globalBindings = new SimpleBindings();
context.setBindings(globalBindings, ScriptContext.GLOBAL_SCOPE);
context.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
globalBindings.put("text", "another text");
engine.eval("print(text)", context);
}
}
- backported by
-
JDK-8081673 engine.eval call from a java method which was called from a previous engine.eval results in wrong ScriptContext being used.
-
- Resolved
-
-
JDK-8085675 engine.eval call from a java method which was called from a previous engine.eval results in wrong ScriptContext being used.
-
- Resolved
-
-
JDK-8129192 engine.eval call from a java method which was called from a previous engine.eval results in wrong ScriptContext being used.
-
- Resolved
-
-
JDK-8129717 engine.eval call from a java method which was called from a previous engine.eval results in wrong ScriptContext being used.
-
- Resolved
-
-
JDK-8138549 engine.eval call from a java method which was called from a previous engine.eval results in wrong ScriptContext being used.
-
- Resolved
-
- relates to
-
JDK-8130751 Nashorn recursive invocation of eval clobbers bindings
-
- Closed
-