-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 9, 10, 11
-
x86_64
-
os_x
FULL PRODUCT VERSION :
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin mac.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
In method
java.text.MessageFormat#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
is unchecked cast from Object to Object[]. in description is described object array, but for example JavaFX is using it wrong and putting here single value as a String in string Bidirectional binding of property.
Simple solution is check given object is array and if not wrap it to array.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(String[] args) {
String res = "";
StringBuffer stringBuffer = new StringBuffer(res);
StringBuffer format = new MessageFormat("DAY {0}").format("1", stringBuffer, new FieldPosition(0));
System.out.println(format);
}
ACTUAL -
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at java.text.MessageFormat.format(MessageFormat.java:865)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at java.text.MessageFormat.format(MessageFormat.java:865)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
String res = "";
StringBuffer stringBuffer = new StringBuffer(res);
StringBuffer format = new MessageFormat("DAY {0}").format("1", stringBuffer, new FieldPosition(0));
System.out.println(format);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use different method, but this method is used by JavaFX :(
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin mac.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
In method
java.text.MessageFormat#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
is unchecked cast from Object to Object[]. in description is described object array, but for example JavaFX is using it wrong and putting here single value as a String in string Bidirectional binding of property.
Simple solution is check given object is array and if not wrap it to array.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(String[] args) {
String res = "";
StringBuffer stringBuffer = new StringBuffer(res);
StringBuffer format = new MessageFormat("DAY {0}").format("1", stringBuffer, new FieldPosition(0));
System.out.println(format);
}
ACTUAL -
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at java.text.MessageFormat.format(MessageFormat.java:865)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at java.text.MessageFormat.format(MessageFormat.java:865)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
String res = "";
StringBuffer stringBuffer = new StringBuffer(res);
StringBuffer format = new MessageFormat("DAY {0}").format("1", stringBuffer, new FieldPosition(0));
System.out.println(format);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use different method, but this method is used by JavaFX :(
- duplicates
-
JDK-4228682 MessageFormat format(Object, StringBuffer, FieldPosition) doesn't work
-
- Closed
-
- relates to
-
JDK-8200352 Improper calling of MessageFormat.format method.
-
- Open
-