harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r772173 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ArrayList.java test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
Date Wed, 06 May 2009 12:26:39 GMT
Author: tellison
Date: Wed May  6 12:26:32 2009
New Revision: 772173

URL: http://svn.apache.org/viewvc?rev=772173&view=rev
Log:
Apply fix for HARMONY-6141 ([classlib][luni] java.util.ArrayList.addAll(int index, Collection<?
extends E> c) fails to add itself)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/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?rev=772173&r1=772172&r2=772173&view=diff
==============================================================================
--- 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 Wed
May  6 12:26:32 2009
@@ -171,6 +171,9 @@
         if (location < 0 || location > size) {
             throw new IndexOutOfBoundsException();
         }
+        if (this == collection) {
+            collection = (ArrayList)clone();
+        }
         int growSize = collection.size();
         if (0 < location && location < size) {
             if (array.length - size < growSize) {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java?rev=772173&r1=772172&r2=772173&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
Wed May  6 12:26:32 2009
@@ -397,6 +397,30 @@
 
     }
 
+        public void test_ArrayList_addAll_scenario1() {
+        ArrayList arrayListA = new ArrayList();
+        arrayListA.add(1);
+        ArrayList arrayListB = new ArrayList();
+        arrayListB.add(1);
+        arrayListA.addAll(1, arrayListB);
+        int size = arrayListA.size();
+        assertEquals(2, size);
+        for (int index = 0; index < size; index++) {
+            assertEquals(1, arrayListA.get(index));
+        }
+    }
+
+    public void test_ArrayList_addAll_scenario2() {
+        ArrayList arrayList = new ArrayList();
+        arrayList.add(1);
+        arrayList.addAll(1, arrayList);
+        int size = arrayList.size();
+        assertEquals(2, size);
+        for (int index = 0; index < size; index++) {
+            assertEquals(1, arrayList.get(index));
+        }
+    }
+        
     // Regression test for HARMONY-5839
     public void testaddAllHarmony5839() {
         Collection coll = Arrays.asList(new String[] { "1", "2" });



Mime
View raw message