Hi Umaoka-san,
Yeah, that looks like a bug to me. Can you please file it, as I wasn't
aware of it being reported.
Naoto
On 10/13/17 10:39 AM, Yoshito Umaoka wrote:
Hello,
I received a problem report from an ICU4J consumer who uses ICU4J Locale SPI
module.
ICU NumberFormatProvider returns a class -
com.ibm.icu.impl.jdkadapter.NumberFormatICU which extends
java.text.NumberFormat.
The ICU4J locale SPI user found the ICU provider causes an issue when he uses
Scanner. I can reproduce the problem on my environment as well. The exception
call stack shows -
Exception in thread "main" java.lang.ClassCastException:
com.ibm.icu.impl.jdkadapter.NumberFormatICU cannot be cast to java.text.DecimalFormat
at java.util.Scanner.useLocale(Scanner.java:1186)
at java.util.Scanner.<init>(Scanner.java:540)
at java.util.Scanner.<init>(Scanner.java:563)
at test.ScannerTest.main(ScannerTest.java:11)
Below is the location in Scanner.java
public Scanner useLocale(Locale locale) {
if (locale.equals(this.locale))
return this;
this.locale = locale;
DecimalFormat df =
(DecimalFormat)NumberFormat.getNumberInstance(locale);
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);
So the implementation blindly cast NumberFormat instance returned by
getNumberIntance(Locale) to DecimalFormat.
I thought I reported this issue before. Are you aware of this issue? Maybe, I
forgot to file a bug when I investigated this earlier in this year, because I
could not find it in java bug.
-Yoshito