harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r832444 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ArrayList.java main/java/org/apache/harmony/luni/internal/nls/messages.properties test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
Date Tue, 03 Nov 2009 15:02:21 GMT
Author: tellison
Date: Tue Nov  3 15:02:20 2009
New Revision: 832444

URL: http://svn.apache.org/viewvc?rev=832444&view=rev
Log:
Apply modified patch for HARMONY-6366 ([classlib][luni]ArrayList does NOT contain exception
message when throw IndexOutOfBoundsException)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
    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=832444&r1=832443&r2=832444&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 Tue
Nov  3 15:02:20 2009
@@ -24,6 +24,8 @@
 import java.io.Serializable;
 import java.lang.reflect.Array;
 
+import org.apache.harmony.luni.internal.nls.Messages;
+
 /**
  * ArrayList is an implementation of {@link List}, backed by an array. All
  * optional operations adding, removing, and replacing are supported. The
@@ -128,7 +130,11 @@
             }
             array[lastIndex++] = object;
         } else {
-            throw new IndexOutOfBoundsException();
+            throw new IndexOutOfBoundsException(
+                    // luni.0A=Index: {0}, Size: {1}
+                    Messages.getString("luni.0A", //$NON-NLS-1$
+                            Integer.valueOf(location),
+                            Integer.valueOf(lastIndex - firstIndex)));
         }
 
         modCount++;
@@ -169,7 +175,11 @@
     public boolean addAll(int location, Collection<? extends E> collection) {
         int size = lastIndex - firstIndex;
         if (location < 0 || location > size) {
-            throw new IndexOutOfBoundsException();
+            throw new IndexOutOfBoundsException(
+                    // luni.0A=Index: {0}, Size: {1}
+                    Messages.getString("luni.0A", //$NON-NLS-1$
+                            Integer.valueOf(location),
+                            Integer.valueOf(lastIndex - firstIndex)));
         }
         if (this == collection) {
             collection = (ArrayList)clone();
@@ -322,7 +332,11 @@
         if (0 <= location && location < (lastIndex - firstIndex)) {
             return array[firstIndex + location];
         }
-        throw new IndexOutOfBoundsException();
+        throw new IndexOutOfBoundsException(
+                // luni.0A=Index: {0}, Size: {1}
+                Messages.getString("luni.0A", //$NON-NLS-1$
+                        Integer.valueOf(location),
+                        Integer.valueOf(lastIndex - firstIndex)));
     }
 
     private void growAtEnd(int required) {
@@ -486,7 +500,11 @@
                 firstIndex = lastIndex = 0;
             }
         } else {
-            throw new IndexOutOfBoundsException();
+            throw new IndexOutOfBoundsException(
+                    // luni.0A=Index: {0}, Size: {1}
+                    Messages.getString("luni.0A", //$NON-NLS-1$
+                            Integer.valueOf(location),
+                            Integer.valueOf(lastIndex - firstIndex)));
         }
 
         modCount++;
@@ -536,7 +554,10 @@
             }
             modCount++;
         } else {
-            throw new IndexOutOfBoundsException();
+            throw new IndexOutOfBoundsException(
+                    // luni.0B=Array index out of range: {0}
+                    Messages.getString("luni.0B", //$NON-NLS-1$
+                            lastIndex - firstIndex - end));
         }
     }
 
@@ -559,7 +580,11 @@
             array[firstIndex + location] = object;
             return result;
         }
-        throw new IndexOutOfBoundsException();
+        throw new IndexOutOfBoundsException(
+                // luni.0A=Index: {0}, Size: {1}
+                Messages.getString("luni.0A", //$NON-NLS-1$
+                        Integer.valueOf(location),
+                        Integer.valueOf(lastIndex - firstIndex)));
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties?rev=832444&r1=832443&r2=832444&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
Tue Nov  3 15:02:20 2009
@@ -24,3 +24,5 @@
 luni.07=The stream is corrupted
 luni.08=Invalid Unicode sequence: expected format \\uxxxx
 luni.09=Invalid Unicode sequence: illegal character
+luni.0A=Index: {0}, Size: {1}
+luni.0B=Array index out of range: {0}

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=832444&r1=832443&r2=832444&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
Tue Nov  3 15:02:20 2009
@@ -124,28 +124,32 @@
             alist.add(-1, new Object());
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(-1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(alist.size() + 1, new Object());
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.add(alist.size() + 1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -229,6 +233,8 @@
             obj.addAll((int) -1, (Collection) null);
             fail("IndexOutOfBoundsException expected");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         // Regression for HARMONY-5705
@@ -296,14 +302,16 @@
             obj.addAll(-1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             obj.addAll(obj.size() + 1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
@@ -317,13 +325,16 @@
             obj.addAll(obj.size() + 1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             obj.addAll((int) -1, (Collection) null);
             fail("IndexOutOfBoundsException expected");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -547,6 +558,8 @@
             alist.get(8765);
             fail("Failed to throw expected exception for index > size");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -603,7 +616,8 @@
             mylist.removeRange(0, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         int[] data = { 1, 2, 3 };
@@ -619,28 +633,32 @@
             mylist.removeRange(-1, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(0, -1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(1, 0);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             mylist.removeRange(2, 1);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
     
@@ -656,6 +674,8 @@
             alist.remove(999);
             fail("Failed to throw exception when index out of range");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         ArrayList myList = (ArrayList) (((ArrayList) (alist)).clone());
@@ -683,11 +703,15 @@
             l.remove(-1);
             fail("-1 should cause exception");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
         try {
             l.remove(0);
             fail("0 should case exception");
         } catch (IndexOutOfBoundsException e) {
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -713,28 +737,32 @@
             alist.set(-1, obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(alist.size(), obj);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(-1, null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
 
         try {
             alist.set(alist.size(), null);
             fail("Should throw IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException e) {
-            // Excepted
+            // Expected
+            assertNotNull(e.getMessage());
         }
     }
 



Mime
View raw message