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

Sparse array does not handle growth of underlying dense array

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 8
    • 9
    • core-libs
    • b85
    • generic
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: