[kaffe] Bug Report: unexpected IllegalArgumentException from java.text.DecimalFormat

Ito Kazumitsu kaz at maczuka.gcd.org
Wed Oct 22 08:43:02 PDT 2003


The attached program gives the following result:

bash-2.05b$ java TestDecimalFormat      
0.00% java.lang.IllegalArgumentException: unexpected special character - index: 4

Which is not the case with Sun's JDK.

In the kaffe world, I applied the following patch:

--- java/text/DecimalFormat.java.orig	Thu Aug 28 00:44:12 2003
+++ java/text/DecimalFormat.java	Wed Oct 22 17:57:28 2003
@@ -205,6 +205,8 @@
 	      }
 	    else if (c != syms.getExponential()
 		     && c != syms.getPatternSeparator()
+		     && c != syms.getPercent()
+		     && c != syms.getPerMill()
 		     && patChars.indexOf(c) != -1)
 	      throw new IllegalArgumentException ("unexpected special " +
 						  "character - index: " + index);


And the program for this case follows:

import java.text.DecimalFormat;

public class TestDecimalFormat {

    public static void main(String[] args) {
        String[] formats = new String[]  {
            "0",
            "0.00",
            "#,##0",
            "#,##0.00",
            "$#,##0;($#,##0)",
            "$#,##0;($#,##0)",
            "$#,##0.00;($#,##0.00)",
            "$#,##0.00;($#,##0.00)",
            "0%",
            "0.00%",
            "0.00E00",
            "#,##0;(#,##0)",
            "#,##0;(#,##0)",
            "#,##0.00;(#,##0.00)",
            "#,##0.00;(#,##0.00)",
            "#,##0;(#,##0)",
            "$#,##0;($#,##0)",
            "#,##0.00;(#,##0.00)",
            "$#,##0.00;($#,##0.00)",
            "##0.0E0" };
        for(int i=0; i < formats.length; i++) {
            try {
                DecimalFormat d = new DecimalFormat(formats[i]);
            }
            catch (Exception e) {
                System.err.println(formats[i] + " " + e);
            }
        }
    }
}




More information about the kaffe mailing list