java.lang.StringBuffer.substring is manipulating the shared flag on the StringBuffer object incorrectly, PR java/12350.
The following patch fixes the bug and adds a test case. It passes the libjava/testsuite on i686-pc-linux-gnu.
Thanks Ralph.
I am checking in a slightly modified patch to both libgcj and classpath.
Regards
Bryce.
2003-09-21 Ralph Loader <[EMAIL PROTECTED]>
PR java/12350:
* java/lang/StringBuffer.java (substring): fix handling of shared flag.Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 StringBuffer.java
--- java/lang/StringBuffer.java 24 Mar 2003 00:50:18 -0000 1.15
+++ java/lang/StringBuffer.java 22 Sep 2003 08:10:44 -0000
@@ -564,8 +564,9 @@
throw new StringIndexOutOfBoundsException();
if (len == 0)
return "";
- // Share the char[] unless 3/4 empty.
- shared = (len << 2) >= value.length;
+ // Share unless substring is smaller than 1/4 of the buffer.
+ if ((len << 2) >= value.length)
+ shared = true;
// Package constructor avoids an array copy.
return new String(value, beginIndex, len, shared);
}
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath

