JDK-8080093 : JSON Parse - leads to java.lang.ArrayIndexOutOfBoundsException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-03-22
  • Updated: 2015-05-28
  • Resolved: 2015-05-12
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
Windows:
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)

Linux:
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)

ADDITIONAL OS VERSION INFORMATION :
Linux manivand.desktop.*****.com 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

NOTE: This is not related to OS. I am able to reproduce the same issue on Windows, Mac & Ubuntu systems.

A DESCRIPTION OF THE PROBLEM :
Nashorn is no longer parsing the below JSON content.
{
    "supportInfo": {
        "210": true,
        "500": false
  }
}

How to reproduce?
1. Goto Java BIN directory
2. Run "jjs",  run the following script.
var jsonString = '{"supportInfo":{"210":true,"500":false}}';
var data = JSON.parse(jsonString);

Error: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 7

REGRESSION.  Last worked in version 8u31

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

How to reproduce?
1. Goto Java BIN directory
2. Run "jjs",  run the following script.
var jsonString = '{"supportInfo":{"210":true,"500":false}}';
var data = JSON.parse(jsonString);
print(data.supportInfo["210"]) //true
print(data.supportInfo["510"]) //false

No errors

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
210
510
Without any error
ACTUAL -
In 1.8.0_31 - No errors works as expected.
In 1.8.0_41 - Error: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 7

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No logs, it looks like a definite software bug.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Not Requried
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Never keep your json property/key as integer. The following json parses fine.

{
    "supportInfo": {
        "_210": true,
        "_500": false
  }
}


Comments
Marking as duplicate of JDK-8074687. Although that is a slightly different bug (lost properties instead of exception) it also fixes this problem. I added tests for the ArrayIndexOutOfVBoundsException in JDK-8074687.
12-05-2015

JDK-8080096 might be a duplicate of this bug.
12-05-2015