I try to make a program using Locale. I want compile natively this program with GraalVM but Locale don't have the same behavior after native compiling.
I success to isolate the problem with the following program :
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Currency;
public class HelloWorld {
public static void main(String[] args) {
NumberFormat gbNumberFormat = NumberFormat.getCurrencyInstance(new Locale("en", "GB"));
gbNumberFormat.setCurrency(Currency.getInstance("USD"));
System.out.println(gbNumberFormat.format(1337));
NumberFormat usNumberFormat = NumberFormat.getCurrencyInstance(new Locale("en", "US"));
usNumberFormat.setCurrency(Currency.getInstance("USD"));
System.out.println(usNumberFormat.format(1337));
}
}
I can compile this program in Java :
javac -d out/ HelloWorld.java
And execute it (from out directory) :
java HelloWorld
The result is :
US$1,337.00
$1,337.00
I can now make the native image and launch it :
native-image -cp out/ HelloWorld
./helloworld
The result is not the same :
$1,337.00
$1,337.00
It is look likes I have a problem with i18n in native mode. I don't really understand why. I am using graalvm-ce-java11-20.0.0 but I tested with previous versions with same behavior.
I am at your disposal if necessary.