JDK-8048718 : JSON.parse('{"0":0, "64":0}') throws ArrayindexOutOfBoundsException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-06-30
  • Updated: 2015-01-21
  • Resolved: 2014-06-30
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 b22Fixed
Description
jjs -J-Djava.ext.dirs=$jdk9_dev/nashorn/dist/ -doe

jjs> JSON.parse('{"0":0, "64":0}')

java.lang.ArrayIndexOutOfBoundsException: 64
java.lang.ArrayIndexOutOfBoundsException: 64
	at jdk.nashorn.internal.runtime.arrays.IntArrayData.set(IntArrayData.java:215)
	at jdk.nashorn.internal.runtime.arrays.IntArrayData.set(IntArrayData.java:204)
	at jdk.nashorn.internal.runtime.arrays.ArrayFilter.set(ArrayFilter.java:102)
	at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.set(DeletedRangeArrayFilter.java:132)
	at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:694)
	at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
	at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
	at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
	at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
	at jdk.nashorn.internal.scripts.Script$Recompilation$3$\^shell\_.:program(<shell>:1)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:567)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:222)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:375)
	at jdk.nashorn.internal.runtime.Context.eval(Context.java:633)
	at jdk.nashorn.internal.runtime.Context.eval(Context.java:563)
	at jdk.nashorn.tools.Shell.readEvalPrint(Shell.java:448)
	at jdk.nashorn.tools.Shell.run(Shell.java:158)
	at jdk.nashorn.tools.Shell.main(Shell.java:133)
	at jdk.nashorn.tools.Shell.main(Shell.java:112)

The above works fine with jdk8 GA as well as jdk8u-dev tip build