JDK-8080096 : Parsing a JSON object with numeric keys fails
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-04-14
  • Updated: 2020-08-05
  • Resolved: 2015-05-12
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
8u60Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

A DESCRIPTION OF THE PROBLEM :
When calling JSON.parse() on a string containing an object with keys that are numbers (as strings), it will fail with 

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 12



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
jjs -scripting
jjs> var f = readFully("test.json");
jjs> JSON.parse(f);
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 12

Test file contents:
{"1":7,"3":2,"5":4,"7":3,"11":11,"12":1,"13":3,"14":1,"17":4,"21":1,"31":2,"51":3,"80":6,"81":15,"91":5,"771":1,"1117":1,"1391":1,"1781":1,"11181":1,"BETTS":67,"BIRCH":226,"BIRCTI":1,"BISHOP":256}



REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Closing as duplicate JDK-8068872 as described in my previous comment.
12-05-2015

This is fixed by JDK-8074687, even though that is a slightly different bug (or different way of failure). Once I realized my fix also solved the ArrayIndexOutOfBoundsException I added additional tests that cover this in JDK-8074687.
12-05-2015

It could be a regression in 8u40 and could be a duplicate of JDK-8080093
12-05-2015