-
Bug
-
Resolution: Fixed
-
P3
-
8u60, 9
-
b105
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8156456 | 8u111 | Michael Haupt | P3 | Resolved | Fixed | b01 |
JDK-8149443 | 8u102 | Michael Haupt | P3 | Resolved | Fixed | b01 |
JDK-8162333 | emb-8u111 | Michael Haupt | P3 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux dev01 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
An empty array created by JSON.parse() behaves differently from an empty array created from an empty array literal.
The empty array from JSON.parse() has length 0, but after calling push() once on the array it has length 2.
The empty array literal behaves as expected - after calling push() once the array has length 1, and the single element in the array is the one pushed into the array.
REGRESSION. Last worked in version 8u60
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the jjs command line tool to run the following:
var a = JSON.parse(JSON.stringify([]));
a.push(10);
a
a.length
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jjs> var a = JSON.parse(JSON.stringify([]));
jjs> a.push(10);
1
jjs> a
10
jjs> a.length
1
ACTUAL -
jjs> var a = JSON.parse(JSON.stringify([]));
jjs> a.push(10);
1
jjs> a
0,10
jjs> a.length
2
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Check for empty array before the push() call, and replace with empty array from array literal.
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux dev01 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
An empty array created by JSON.parse() behaves differently from an empty array created from an empty array literal.
The empty array from JSON.parse() has length 0, but after calling push() once on the array it has length 2.
The empty array literal behaves as expected - after calling push() once the array has length 1, and the single element in the array is the one pushed into the array.
REGRESSION. Last worked in version 8u60
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the jjs command line tool to run the following:
var a = JSON.parse(JSON.stringify([]));
a.push(10);
a
a.length
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jjs> var a = JSON.parse(JSON.stringify([]));
jjs> a.push(10);
1
jjs> a
10
jjs> a.length
1
ACTUAL -
jjs> var a = JSON.parse(JSON.stringify([]));
jjs> a.push(10);
1
jjs> a
0,10
jjs> a.length
2
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Check for empty array before the push() call, and replace with empty array from array literal.
- backported by
-
JDK-8149443 JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
- Resolved
-
JDK-8156456 JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
- Resolved
-
JDK-8162333 JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
- Resolved