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

java.text.MessageFormat.setFormat(int n, Format f) fails with an illegal n

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.5
    • Verified



      Name: dfC67450 Date: 04/24/98



      java.text.MessageFormat.setFormat(int n, Format format) throws unexpected
      ArrayIndexOutOfBoundsException when n is invalid (n < 0). Javadoc says
      nothing about this behavior.
      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;
      public class Test {
          public static void main (String args[]){
            MessageFormat mf = new MessageFormat("arg: {0}");
            try {
              mf.setFormat(-1, NumberFormat.getInstance());
            } catch (IllegalArgumentException e) {
              System.out.println("Test passed");
            } catch (ArrayIndexOutOfBoundsException e) {
              System.out.println("Test failed. It throws " + e);
            }
          }

      }

      ---------Output from the test---------------------
      Test failed. It throws java.lang.ArrayIndexOutOfBoundsException: -1
      --------------------------------------------------

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

            aliusunw Alan Liu (Inactive)
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: