Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8138632

Sparse array does not handle growth of underlying dense array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b85
    • CPU:
      generic
    • OS:
      generic

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                hannesw Hannes Wallnoefer
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: