gcc/libjava/testsuite/libjava.lang/PR12350.java
Ralph Loader 88962108fc re PR libgcj/12350 (StringBuffer.substring handles shared flag incorrected.)
2003-09-21  Ralph Loader  <suckfish@ihug.co.nz>

        PR java/12350:
        * java/lang/StringBuffer.java (substring): Fix handling of shared
        flag.

2003-09-21  Ralph Loader  <suckfish@ihug.co.nz>

        PR java/12350
        * libjava.lang/PR12350.java: New file.
        * libjava.lang/PR12350.out: New file.

From-SVN: r71651
2003-09-22 09:17:49 +01:00

21 lines
466 B
Java

public class PR12350
{
static public void main (String[] ignored) throws Throwable
{
StringBuffer b = new StringBuffer ("Good string. More than 16 chars.");
// Should cause sharing.
String s = b.toString();
// Take a char by char unshared copy of s.
String t = new String (s.toCharArray());
b.substring (0, 4); // BUG: Clears shared flag.
b.replace (0, 4, "Bad "); // Modifies shared data.
System.out.println (s);
assert s.equals (t);
}
}