JDK-8067854 : bound java static method throws NPE when 'null' is used for this argument
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-12-18
  • Updated: 2015-09-29
  • Resolved: 2014-12-18
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
8u60Fixed 9 b44Fixed
Description
File: getjavahome.js

getProp = java.lang.System.getProperty;
getHome = Function.prototype.bind.call(getProp, null, "java.home");
print(getHome()); // JAVA_HOME value expected


Expected:

JAVA_HOME is printed.

Actual:

Exception in thread "main" java.lang.NullPointerException
	at jdk.nashorn.internal.runtime.linker.BoundCallableLinker.getGuardedInvocation(BoundCallableLinker.java:102)
	at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
	at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
	at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:149)
	at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:233)
	at jdk.nashorn.internal.scripts.Script$Recompilation$4$getjavahome$cu1$restOf.:program(getjavahome.js:3)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	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)