You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the JSR-223 compliant ScriptEngine implementation, GraalJSScriptEngine will throw a NPE when setting empty bindings with ENGINE_SCOPE:
importjavax.script.Bindings;
importjavax.script.ScriptContext;
importjavax.script.ScriptEngine;
importjavax.script.ScriptEngineManager;
publicclassEngineScopeBindingsNPE {
publicstaticvoidmain(String[] args) {
ScriptEngineManagerengineManager = newScriptEngineManager();
ScriptEngineengine = engineManager.getEngineByName("graal.js");
if (engine == null) {
System.out.println("graal.js engine not found");
return;
}
Bindingsbindings = engine.createBindings();
engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
if (engine.getBindings(ScriptContext.ENGINE_SCOPE) != bindings) {
thrownewError("Should be the same");
}
}
}
Executing this program will result in:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.graalvm.polyglot.Context.eval(org.graalvm.polyglot.Source)" because "context" is null
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.evalInternal(GraalJSScriptEngine.java:408)
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSBindings.updateBinding(GraalJSBindings.java:121)
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSBindings.updateContextBinding(GraalJSBindings.java:111)
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSBindings.updateEngineScriptContext(GraalJSBindings.java:222)
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.setBindings(GraalJSScriptEngine.java:426)
at EngineScopeBindingsNPE.main(EngineScopeBindingsNPE.java:16)
The text was updated successfully, but these errors were encountered:
Fixesoracle#839
Cherry picked from:
69c6c87: GraalJSScriptEngine: NPE when setting empty engine bindings
16d63fa: Correction of the year in the copyright header.
When using the JSR-223 compliant ScriptEngine implementation,
GraalJSScriptEngine
will throw a NPE when setting empty bindings withENGINE_SCOPE
:Executing this program will result in:
The text was updated successfully, but these errors were encountered: