JDK-8068872 : Nashorn JSON.parse drops numeric keys
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 8u40
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-01-10
  • Updated: 2015-09-29
  • Resolved: 2015-02-05
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
8u60 b03Fixed 9Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
openjdk version "1.8.0_40-internal"
OpenJDK Runtime Environment (build 1.8.0_40-internal-b09)
OpenJDK 64-Bit Server VM (build 25.40-b13, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
JSON.parse drops numeric properties in certain cases, apparently when they are not in increasing order.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ jjs
jjs> JSON.stringify(JSON.parse('{"5": true, "3": "a"}'))
{"3":"a"}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
$ jjs
jjs> JSON.stringify(JSON.parse('{"5": true, "3": "a"}'))
{"3":"a", "5": true}

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Verified 8u60 b06 all platforms with regtest.
20-03-2015

The issue here was that ArrayData.ensure should only update the length if the new index is greater or equal to the old length.
05-02-2015

Could reproduce this with JDK 8u40 and JDK 9b38. Works fine with JDK 8u25.
13-01-2015

Could reproduce with Java(TM) SE Runtime Environment (build 1.9.0-ea-b44) as well. Key "5" is dropped in jdk9 too.
13-01-2015