harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r399206 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/StringBuilder.java test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java
Date Wed, 03 May 2006 08:42:00 GMT
Author: tellison
Date: Wed May  3 01:41:57 2006
New Revision: 399206

URL: http://svn.apache.org/viewcvs?rev=399206&view=rev
Log:
Fix for HARMONY-348 (java.lang.StringBuilder.replace does not get right result)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringBuilder.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringBuilder.java?rev=399206&r1=399205&r2=399206&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringBuilder.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringBuilder.java
Wed May  3 01:41:57 2006
@@ -1030,13 +1030,18 @@
         if (start == length) {
             return append(str);
         }
-
+        if(end > length) {
+            end = length;
+        }
         int sbLen = end - start;
         int strLen = str.length();
         if (strLen > sbLen) {
             // shift chars with an insert of the difference
             // this will handle capacity and length management
             insert(start, new char[strLen - sbLen]);
+        }
+        if(strLen < sbLen) {
+            delete(start, start + sbLen-strLen);
         }
         // copy in new chars
         for (int i = 0, j = start; i < strLen; i++, j++)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java?rev=399206&r1=399205&r2=399206&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java
Wed May  3 01:41:57 2006
@@ -1526,6 +1526,11 @@
 		} catch (StringIndexOutOfBoundsException e) {
 			// Expected
 		}
+
+		// Regression for HARMONY-348
+		StringBuilder buffer = new StringBuilder("1234567");
+		buffer.replace(2, 6, "XXX");
+		assertEquals("12XXX7",buffer.toString());
 	}
 
 	/**



Mime
View raw message