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.
8u72Fixed 9 b85Fixed
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;

Expected output: 

Actual output:

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