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

8309622: Re-examine the cache mechanism in BaseLocale #1349

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Backport 8330802: Desugar switch in Locale::createLocale
GoeLin committed Jan 21, 2025
commit 6cfd22bae096461a47b96756d2c685f3bb674529
10 changes: 5 additions & 5 deletions src/java.base/share/classes/java/util/Locale.java
Original file line number Diff line number Diff line change
@@ -927,11 +927,11 @@ static Locale getInstance(BaseLocale baseloc, LocaleExtensions extensions) {

private static final ReferencedKeyMap<Object, Locale> LOCALE_CACHE = ReferencedKeyMap.create(true, ConcurrentHashMap::new);
private static Locale createLocale(Object key) {
return switch (key) {
case BaseLocale base -> new Locale(base, null);
case LocaleKey lk -> new Locale(lk.base, lk.exts);
default -> throw new InternalError("should not happen");
};
if (key instanceof BaseLocale base) {
return new Locale(base, null);
}
LocaleKey lk = (LocaleKey)key;
return new Locale(lk.base, lk.exts);
}

private static final class LocaleKey {