JDK-8138632 : Sparse array does not handle growth of underlying dense array
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-09-30
  • Updated: 2016-01-14
  • Resolved: 2015-10-01
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
8u72Fixed 9 b85Fixed
Description
When an element is set in a sparse array that is stored in the underlying dense array and causes the dense array to grow, the elements between the old dense array length and the new index are not deleted. 

var x = [];
x[10000000] = 1;
x[10] = 1;
x[20] = 1;
print(Object.keys(x));

Expected output: 
10,20,10000000

Actual output:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,10000000

The fix is to add functionality similar to that in ScriptObject.doesNotHaveEnsureDelete in SparseArrayData.set.

Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/6adb23130ed6 User: lana Date: 2015-10-07 15:58:54 +0000
07-10-2015

URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/6adb23130ed6 User: hannesw Date: 2015-10-01 08:37:50 +0000
01-10-2015