JDK-8037486 : "Java.to" tries to unbox integers in object only function in the optimistic world
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2014-03-16
  • Updated: 2014-06-24
  • Resolved: 2014-06-24
Related Reports
Duplicate :  
Description
Latest staging repo:

var x = Java.to([null], "java.lang.Integer[]")[0];                                                                                                                                                                                                                       
print(x);     

This produces a null pointer 

Exception in thread "main" java.lang.NullPointerException
	at sun.invoke.util.ValueConversions.unboxInteger(ValueConversions.java:77)
	at jdk.nashorn.internal.scripts.Script$jac.:program(jac.js:33)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:506)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:216)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:376)
	at jdk.nashorn.tools.Shell.apply(Shell.java:385)
	at jdk.nashorn.tools.Shell.runScripts(Shell.java:314)
	at jdk.nashorn.tools.Shell.run(Shell.java:168)
	at jdk.nashorn.tools.Shell.main(Shell.java:132)
	at jdk.nashorn.tools.Shell.main(Shell.java:111)


Not sure why
Comments
Most likely because we assign x 59 invokedynamic dyn:setProp|setElem:x(Object;I)V [static 'bootstrap' args=0x5] Where, we really did get back an object. And there are no optimistic setters
16-03-2014