harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r521638 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ArrayList.java test/java/tests/api/java/util/ArrayListTest.java
Date Fri, 23 Mar 2007 09:16:59 GMT
Author: liangyx
Date: Fri Mar 23 02:16:58 2007
New Revision: 521638

URL: http://svn.apache.org/viewvc?view=rev&rev=521638
Log:
Apply patch for HARMONY-3481([classlib][luni] ArrayList throw ArrayIndexOutOfBoundsException
when invoking addAll(Collection) after removing some elements)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java?view=diff&rev=521638&r1=521637&r2=521638
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java Fri
Mar 23 02:16:58 2007
@@ -356,7 +356,9 @@
             }
 			E[] newArray = newElementArray(size + increment);
 			if (size > 0) {
-                System.arraycopy(array, firstIndex, newArray, firstIndex, size);
+                System.arraycopy(array, firstIndex, newArray, 0, size);
+                firstIndex = 0;
+                lastIndex = size;
             }
 			array = newArray;
 		}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java?view=diff&rev=521638&r1=521637&r2=521638
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java
Fri Mar 23 02:16:58 2007
@@ -188,12 +188,29 @@
 				.get(101) == i.next());
 		assertTrue("Item at slot 103 is wrong: " + alist.get(102), alist
 				.get(102) == i.next());
+        
+        
+        // Regression test for Harmony-3481
+        ArrayList<Integer> originalList = new ArrayList<Integer>(12);
+        for (int j = 0; j < 12; j++) {
+            originalList.add(j);
+        }
+        
+        originalList.remove(0);
+        originalList.remove(0);
+        
+        ArrayList<Integer> additionalList = new ArrayList<Integer>(11);
+        for (int j = 0; j < 11; j++) {
+            additionalList.add(j);
+        }
+        assertTrue(originalList.addAll(additionalList));
+        assertEquals(21, originalList.size());
 
 	}
 
 	/**
-	 * @tests java.util.ArrayList#clear()
-	 */
+     * @tests java.util.ArrayList#clear()
+     */
 	public void test_clear() {
 		// Test for method void java.util.ArrayList.clear()
 		alist.clear();



Mime
View raw message