Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-57624] [24.2] NPE in Locale processing with JDK 24+10 and better #9526

Closed
jerboaa opened this issue Aug 19, 2024 · 0 comments · Fixed by #9527
Closed

[GR-57624] [24.2] NPE in Locale processing with JDK 24+10 and better #9526

jerboaa opened this issue Aug 19, 2024 · 0 comments · Fixed by #9527
Assignees
Labels
bug native-image openjdk-updates Related to compatibility with upstream JDK changes redhat-interest

Comments

@jerboaa
Copy link
Collaborator

jerboaa commented Aug 19, 2024

Describe the issue
A new JDK fix in JDK 24+10 causes NullPointerException when some Locale classes are being used in a native image.

Steps to reproduce the issue

  1. Build Graal master (revision 152bcf2f6a4d1080b707258d4a5fdf27f51f4c69) with JDK 24+10 or better.
  2. Generate a native image from the provided reproducer.
  3. Run the reproducer.

Reproducer code

$ cat TestLocale.java 
import java.util.Locale;
public class TestLocale {
	public static void main(String[] args) {
		Locale some = Locale.of("de", "AT");
		System.out.println("Country: " + some.getDisplayCountry());
	}
}
$ $GRAALVM_HOME/bin/java  TestLocale.java
Country: Austria

Describe GraalVM and your environment:

  • GraalVM master built from source
  • JDK major version: 24+10
  • OS: Linux
  • Architecture: AMD64

More details
When running the produced native image one can observe an NPE:

$ ./loc-test
Exception in thread "main" java.lang.NullPointerException
	at java.base@24-beta/sun.util.locale.provider.LocaleResources.getLocaleName(LocaleResources.java:294)
	at java.base@24-beta/sun.util.locale.provider.LocaleNameProviderImpl.getDisplayString(LocaleNameProviderImpl.java:198)
	at java.base@24-beta/sun.util.locale.provider.LocaleNameProviderImpl.getDisplayCountry(LocaleNameProviderImpl.java:147)
	at java.base@24-beta/java.util.Locale$LocaleNameGetter.getObject(Locale.java:2652)
	at java.base@24-beta/java.util.Locale$LocaleNameGetter.getObject(Locale.java:2634)
	at java.base@24-beta/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:284)
	at java.base@24-beta/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:245)
	at java.base@24-beta/java.util.Locale.getDisplayString(Locale.java:2144)
	at java.base@24-beta/java.util.Locale.getDisplayCountry(Locale.java:2130)
	at java.base@24-beta/java.util.Locale.getDisplayCountry(Locale.java:2109)
	at TestLocale.main(TestLocale.java:5)
	at java.base@24-beta/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

Building GraalVM master on the same revision with JDK 24+9 works. We've determined that the issue is being caused by the JDK 24 fix new in build 10: https://bugs.openjdk.org/browse/JDK-8337603

@jerboaa jerboaa self-assigned this Aug 19, 2024
jerboaa added a commit to jerboaa/graal that referenced this issue Aug 19, 2024
The JDK's StaticProperty class uses a default of the empty string
for the java.locale.useOldISOCodes static property. Ensure to also
use the empty string as the default in substratevm avoiding the
NullPointerException.

Closes: oracle#9526
@zakkak zakkak added the openjdk-updates Related to compatibility with upstream JDK changes label Aug 21, 2024
@fniephaus fniephaus changed the title [24.2] NPE in Locale processing with JDK 24+10 and better [GR-57624] [24.2] NPE in Locale processing with JDK 24+10 and better Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug native-image openjdk-updates Related to compatibility with upstream JDK changes redhat-interest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants