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

java.text.ChoiceFormat.ctor(double[], String[]) allows unordered double array.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: dfC67450 Date: 01/26/98



      java.text.ChoiceFormat.ctor(double[] limits, String[] formats) does not check
      whether double array is in ascending sorted order.

      Javadoc says about setChoices method:

           * @param limits contains the top value that you want
           * parsed with that format,and should be in ascending sorted order.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              double[] limits = {3, 1, 2};
              String[] formats = {"Three", "One", "Two"};
              ChoiceFormat cf = new ChoiceFormat(limits, formats);
              double d = 5.0;
              System.out.println("format(" + d + ") = " + cf.format(d));
          }
      }

      ---------Output from the test---------------------
      format(5.0) = Two
      --------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            duke J. Duke (Inactive)
            Reporter:
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: