harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r486093 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/AbstractStringBuilder.java test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
Date Tue, 12 Dec 2006 11:05:18 GMT
Author: liangyx
Date: Tue Dec 12 03:05:17 2006
New Revision: 486093

URL: http://svn.apache.org/viewvc?view=rev&rev=486093
Log:
Throw StringIndexOutOfBoundsException instead of ArrayIndexOutOfBoundsException

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java?view=diff&rev=486093&r1=486092&r2=486093
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
Tue Dec 12 03:05:17 2006
@@ -326,7 +326,7 @@
                 }
                 return;
             }
-            throw new ArrayIndexOutOfBoundsException();
+            throw new StringIndexOutOfBoundsException("offset " + start + ", len " + length
+ ", array.length " + chars.length);
         }
         throw new StringIndexOutOfBoundsException(index);
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java?view=diff&rev=486093&r1=486092&r2=486093
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
Tue Dec 12 03:05:17 2006
@@ -347,18 +347,22 @@
 		// java.lang.StringBuffer.insert(int, char [], int, int)
 		char[] c = new char[] { 'n', 'o', 't', ' ' };
 		testBuffer.insert(8, c, 0, 4);
-		assertTrue("Insert failed: " + testBuffer.toString(), testBuffer
-				.toString().equals("This is not a test buffer"));
+		assertEquals("This is not a test buffer", testBuffer.toString());
 
-		boolean exception = false;
 		StringBuffer buf1 = new StringBuffer("abcd");
 		try {
 			buf1.insert(-1, (char[]) null, 0, 0);
+            fail("Should throw StringIndexOutOfBoundsException");
 		} catch (StringIndexOutOfBoundsException e) {
-			exception = true;
-		} catch (NullPointerException e) {
+            //expected
 		}
-		assertTrue("Should throw StringIndexOutOfBoundsException", exception);
+        
+        try {
+            testBuffer.insert(testBuffer.length() - 1, c, -1, 1);
+        } catch (StringIndexOutOfBoundsException e) {
+            //expected
+        }
+		
 	}
 
 	/**



Mime
View raw message