JDK-8046215 : Running uncompilable scripts throws NullPointerException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-06-06
  • Updated: 2015-01-21
  • Resolved: 2014-06-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b19Fixed
Description
Fix for JDK-8046014 removes the null-check for the script class in Context.getProgramFunction(), causing a NullPointerException down the line for scripts that fail to compile:

Exception in thread "main" java.lang.NullPointerException
	at java.lang.invoke.MethodHandles$Lookup.checkSymbolicClass(MethodHandles.java:1390)
	at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1373)
	at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:774)
	at jdk.nashorn.internal.runtime.Context.getCreateProgramFunctionHandle(Context.java:1025)
	at jdk.nashorn.internal.runtime.Context.getProgramFunction(Context.java:1020)
	at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1042)
	at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:520)
	at jdk.nashorn.tools.Shell.runScripts(Shell.java:314)
	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)