Name: bb33257 Date: 11/24/97
In the latest 1.2 source workspace that we (Taligent) have, there
is a serious problem in String and StringBuffer. If you run the
following code:
StringBuffer b = new StringBuffer("foo");
String s1 = b.toString();
b.setLength(0);
b.append("bar");
String s2 = b.toString();
System.out.println("S1: "+s1+", S2: "+s2);
it will print "S1: bar, S2: bar" rather than "S1: foo, S2: bar".
It appears that there's some overzealous buffer sharing going on
between String and StringBuffer. If String and StringBuffer are
sharing the same buffer, they need to use a copy-on-write
implementation to make sure that a String can never be changed
once it's constructed.
This problem is blocking us from getting our remaining I18N bug
fixes integrated into 1.2.
======================================================================
- duplicates
-
JDK-4089062 String created from StringBuffer overwritten via setLength(0)
-
- Closed
-