-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6, 1.2.0
-
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
--------------------------------------------------
======================================================================