- 
    Bug 
- 
    Resolution: Fixed
- 
     P3 P3
- 
    1.1.5, 1.1.6, 1.2.0
- 
        1.2beta4
- 
        x86, sparc
- 
        solaris_2.5, windows_nt
- 
        Verified
Name: dfC67450 Date: 03/11/98
Object[] java.text.MessageFormat.parse(String text, ParsePosition pp)
fails when first formatter is ChoiceFormat and first prefix has length
greater than 2.
Here is the test demonstrating the bug:
-----------------TestMF.java------------------------
import java.text.*;
public class TestMF {
public static void main (String args[]){
MessageFormat mf = new MessageFormat("");
String pattern = "{0,choice,1#YES|2#NO}";
String prefix = "";
for (int i = 0; i < 5; i++) {
String formatted = prefix + "YES";
mf.applyPattern(prefix + pattern);
prefix += "x";
Object[] objs = mf.parse(formatted, new ParsePosition(0));
System.out.println(i + ". pattern :\"" + mf.toPattern() + "\"");
System.out.print(" \"" + formatted + "\" parsed as ");
if (objs == null) System.out.println(" null");
else System.out.println(" " + objs[0]);
}
}
}
---------Output from the test ---------------------
0. pattern :"{0,choice,1.0#YES|2.0#NO}"
"YES" parsed as 1.0
1. pattern :"x{0,choice,1.0#YES|2.0#NO}"
"xYES" parsed as 1.0
2. pattern :"xx{0,choice,1.0#YES|2.0#NO}"
"xxYES" parsed as 1.0
3. pattern :"xxx{0,choice,1.0#YES|2.0#NO}"
"xxxYES" parsed as null
4. pattern :"xxxx{0,choice,1.0#YES|2.0#NO}"
"xxxxYES" parsed as null
--------------------------------------------------
======================================================================