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)
{