FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
no required.
A DESCRIPTION OF THE PROBLEM :
After testing java.text.MessageFormat, I got several errors but one of them waas inconsistent.
Checking into src.zip, I realized that in method:
private void makeFormat(int position, int offsetNumber, StringBuffer[] segments)
At line 1433 "IllegalArgumentException" is thrown as follows:
default:
maxOffset = oldMaxOffset;
throw new IllegalArgumentException("unknown format type at ");
}
It should be:
default:
maxOffset = oldMaxOffset;
throw new IllegalArgumentException("unknown format type at "+<theIndexOrPosition>);
}
Just like in line 1330 and 1333:
try {
argumentNumber = Integer.parseInt(segments[1].toString()); // always unlocalized!
} catch (NumberFormatException e) {
throw new IllegalArgumentException("can't parse argument number " + segments[1]);
}
if (argumentNumber < 0) {
throw new IllegalArgumentException("negative argument number " + argumentNumber);
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
MessageFormat.format(
"This is a message: {1,asdf}",
new Object[] {"val0", "val1" }
)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Message should include position:
Exception in thread "main" java.lang.IllegalArgumentException: unknown format type at <POSITION>
at java.text.MessageFormat.makeFormat(MessageFormat.java:1433)
at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
at java.text.MessageFormat.<init>(MessageFormat.java:350)
at java.text.MessageFormat.format(MessageFormat.java:803)
at test.Test.breakMessageFormat(Test.java:134)
at test.Test.main(Test.java:76)
ACTUAL -
Message does not include position:
Exception in thread "main" java.lang.IllegalArgumentException: unknown format type at
at java.text.MessageFormat.makeFormat(MessageFormat.java:1433)
at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
at java.text.MessageFormat.<init>(MessageFormat.java:350)
at java.text.MessageFormat.format(MessageFormat.java:803)
at test.Test.breakMessageFormat(Test.java:134)
at test.Test.main(Test.java:76)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: unknown format type at
at java.text.MessageFormat.makeFormat(MessageFormat.java:1433)
at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
at java.text.MessageFormat.<init>(MessageFormat.java:350)
at java.text.MessageFormat.format(MessageFormat.java:803)
at test.Test.breakMessageFormat(Test.java:134)
at test.Test.main(Test.java:76)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] p_args) {
MessageFormat.format(
"This is a message: {1,asdf}", new Object[] {"val0", "val1" }
)
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workarounds.