changeset 1179:1f3e41112f46

8072626: Test for JDK-8068872 fails in tip Reviewed-by: lagergren, jlaskey
author hannesw
date Thu, 05 Feb 2015 16:26:36 +0100
parents 2b9af466a49d
children 32e48a0d59e1
files src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java	Thu Feb 05 14:47:28 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java	Thu Feb 05 16:26:36 2015 +0100
@@ -232,12 +232,13 @@
         final long oldLength = arrayData.length();
         final long longIndex = ArrayIndex.toLongIndex(index);
         ArrayData newArrayData = arrayData;
-        if (longIndex > oldLength) {
-            if (arrayData.canDelete(oldLength, longIndex - 1, false)) {
+        if (longIndex >= oldLength) {
+            newArrayData = newArrayData.ensure(longIndex);
+            if (longIndex > oldLength) {
                 newArrayData = newArrayData.delete(oldLength, longIndex - 1);
             }
         }
-        return newArrayData.ensure(longIndex).set(index, value, false);
+        return newArrayData.set(index, value, false);
     }
 
     private static PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,