A NullPointerException occurs when installing scripts from persistent cache with optimistic types disabled. When running the script below twice: $ java -jar dist/nashorn.jar --optimistic-types=false -pcc ./test/script/basic/JDK-8048079_2a.js parsed and compiled ok prototype.js $ java -jar dist/nashorn.jar --optimistic-types=false -pcc ./test/script/basic/JDK-8048079_2a.js Exception in thread "main" java.lang.NullPointerException at jdk.nashorn.internal.runtime.Context.install(Context.java:1249) at jdk.nashorn.internal.runtime.Context.compile(Context.java:1192) at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1123) at jdk.nashorn.internal.runtime.Context.evaluateSource(Context.java:1089) at jdk.nashorn.internal.runtime.Context.load(Context.java:773) at jdk.nashorn.internal.objects.Global.load(Global.java:1000) at jdk.nashorn.internal.scripts.Script$JDK_8048079_2a.:program(./test/script/basic/JDK-8048079_2a.js:34) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387) at jdk.nashorn.tools.Shell.apply(Shell.java:394) at jdk.nashorn.tools.Shell.runScripts(Shell.java:323) at jdk.nashorn.tools.Shell.run(Shell.java:169) at jdk.nashorn.tools.Shell.main(Shell.java:133) at jdk.nashorn.tools.Shell.main(Shell.java:112) Obviously a function in the constants array may not have an initializer when lazy compilation is enabled, so we need to add a null check right there.
|