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