jshell-scriptengine icon indicating copy to clipboard operation
jshell-scriptengine copied to clipboard

npe on setup that works with nashorn js engine

Open garth0jsonar opened this issue 4 years ago • 1 comments

evaluating this:

var foo="dfsf";

I get this:

00:07:19.969 AWT-EventQueue-0 UtilSwing.eval: rt ex=java.lang.NullPointerException
java.lang.NullPointerException
	at ch.obermuhlner.scriptengine.jshell.JShellCompiledScript.setBindingsValue(JShellCompiledScript.java:84)

this is because global bindings are null there:

        if (!engineBindings.containsKey(name) && globalBindings.containsKey(name)) {

1.1.0 , latest adopt jdk 11. Suggest always init globalBindings.

garth0jsonar avatar May 14 '21 07:05 garth0jsonar

In JShellCompiledScript (35):

        Bindings globalBindings = context.getBindings(ScriptContext.GLOBAL_SCOPE);

can return null.

garth0jsonar avatar May 14 '21 07:05 garth0jsonar