Skip to content

[JDK-8358675] Adapt JDK-8358426: Improve lazy computation in Locale #11341

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

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-26+2-38", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-26+2-45", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ public class LocalizationFeature implements InternalFeature {

private Function<String, Class<?>> findClassByName;

private Field baseLocaleCacheField;
private Field localeCacheField;
private Field candidatesCacheField;
private Field localeObjectCacheMapField;
private Field langAliasesCacheField;
private Field parentLocalesMapField;
@Platforms(Platform.HOSTED_ONLY.class) private ImageClassLoader imageClassLoader;
Expand Down Expand Up @@ -291,9 +288,6 @@ public void duringSetup(DuringSetupAccess a) {
}
langAliasesCacheField = access.findField(CLDRLocaleProviderAdapter.class, "langAliasesCache");
parentLocalesMapField = access.findField(CLDRLocaleProviderAdapter.class, "parentLocalesMap");
baseLocaleCacheField = access.findField("sun.util.locale.BaseLocale$1InterningCache", "CACHE");
localeCacheField = access.findField("java.util.Locale$LocaleCache", "LOCALE_CACHE");
localeObjectCacheMapField = null;
candidatesCacheField = access.findField("java.util.ResourceBundle$Control", "CANDIDATES_CACHE");

String reason = "All ResourceBundleControlProvider that are registered as services end up as objects in the image heap, and are therefore registered to be initialized at image build time";
Expand Down Expand Up @@ -346,27 +340,11 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
@Override
public void duringAnalysis(DuringAnalysisAccess a) {
DuringAnalysisAccessImpl access = (DuringAnalysisAccessImpl) a;
scanLocaleCache(access, baseLocaleCacheField);
scanLocaleCache(access, localeCacheField);
scanLocaleCache(access, candidatesCacheField);
access.rescanRoot(candidatesCacheField);
access.rescanRoot(langAliasesCacheField);
access.rescanRoot(parentLocalesMapField);
}

private void scanLocaleCache(DuringAnalysisAccessImpl access, Field cacheFieldField) {
access.rescanRoot(cacheFieldField);

Object localeCache;
try {
localeCache = cacheFieldField.get(null);
} catch (ReflectiveOperationException ex) {
throw VMError.shouldNotReachHere(ex);
}
if (localeCache != null && localeObjectCacheMapField != null) {
access.rescanField(localeCache, localeObjectCacheMapField);
}
}

@Platforms(Platform.HOSTED_ONLY.class)
private static Set<Locale> processLocalesOption() {
Set<Locale> locales = new HashSet<>();
Expand Down
Loading