On 05/06/2008, Christian Thalinger <[EMAIL PROTECTED]> wrote: > Hi! > > I think I found a bug in GNU Classpath, in java/text/ChoiceFormat.java. > The following Mauve test fails with CACAO (but works with JamVM?!?, > maybe a VM interface issue): > > $ echo gnu/testlet/java/text/ChoiceFormat/parse | cacao RunnerProcess > newPattern=1.0#Sun|2.0#Mon|3.0#Tue|4.0#Wed|5.0#Thu|6.0#Fri|7.0#Sat > buf=Sun > stringVec=[Sun] > buf=Mon > stringVec=[Mon, Mon] > buf=Tue > stringVec=[Tue, Tue, Tue] > buf=Wed > stringVec=[Wed, Wed, Wed, Wed] > buf=Thu > stringVec=[Thu, Thu, Thu, Thu, Thu] > buf=Fri > stringVec=[Fri, Fri, Fri, Fri, Fri, Fri] > buf=Sat > stringVec=[Sat, Sat, Sat, Sat, Sat, Sat, Sat] > > As you can see, Vector.addElement() adds an element and magically > replaces all other elements already in the Vector. This is because > CPStringBuilder.toString() does not generate a copy of the object. > > The attached patch simply uses StringBuilder instead of CPStringBuilder > where the toString() method is used. > > - twisti > > --- > > Index: java/text/ChoiceFormat.java > =================================================================== > RCS file: /sources/classpath/classpath/java/text/ChoiceFormat.java,v > retrieving revision 1.15 > diff -u -3 -p -r1.15 ChoiceFormat.java > --- java/text/ChoiceFormat.java 6 May 2008 22:20:40 -0000 1.15 > +++ java/text/ChoiceFormat.java 5 Jun 2008 14:17:56 -0000 > @@ -40,6 +40,7 @@ exception statement from your version. * > package java.text; > > import gnu.java.lang.CPStringBuilder; > +import java.lang.StringBuilder; > > import java.util.Vector; > > @@ -100,7 +101,7 @@ public class ChoiceFormat extends Number > int index = 0, max = newPattern.length(); > Vector stringVec = new Vector (); > Vector limitVec = new Vector (); > - final CPStringBuilder buf = new CPStringBuilder (); > + final StringBuilder buf = new StringBuilder (); > > while (true) > { > > > >
Are you sure CACAO is using the most up-to-date version of Classpath given this works with JamVM? If buf is being altered, a new array will be created inside CPStringBuffer. If a new buffer is not being created, we should fix the bug in CPStringBuilder, not in this class. -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8