Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4024895

java.text.ChoiceFormat.format() causes StackOverflowError

XMLWordPrintable

    • 1.1fcs
    • x86
    • generic
    • Not verified


      masayoshi.okutsu@Eng 1997-01-09
      java.text.ChoiceFormat.format(long, StringBuffer, FormatStatus) causes
      StackOverflowError. To reproduce, exec the following test program.

      import java.text.*;

      public class bug1{
          public static void main(String[] args){
      //
              double[] limit = {0.0,1.0,2.0};
              Object[] format = {"0.0<=Limit<1.0",
                                  "1.0<=Limit<2.0",
                                  "2.0<=Limit"};
              ChoiceFormat cf = new ChoiceFormat(limit,format);
              FormatStatus status = new FormatStatus();
              StringBuffer toappendTo = new StringBuffer("");
      //
      // main
      //
      // System.out.println(cf.format((double)1.0,toappendTo,status)); // OK
              System.out.println(cf.format((long )1.0,toappendTo,status)); // NG
          }
      }

      Exec result:

      [F:\TEMP\text]java bug1
      java.lang.StackOverflowError
          at java.text.ChoiceFormat.format(ChoiceFormat.java:131)
          at java.text.ChoiceFormat.format(ChoiceFormat.java:131)
               ...
          (lots of iteration)
               ...
          at java.text.ChoiceFormat.format(ChoiceFormat.java:131)
          at java.text.ChoiceFormat.format(ChoiceFormat.java:131)
          at bug1.main(bug1.java:17)

            bcbeck Brian Beck (Inactive)
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: