<i18n dev> RFR: 8309622: Re-examine the cache mechanism in BaseLocale [v3]

Brett Okken duke at openjdk.org
Fri Jun 16 23:42:07 UTC 2023


On Fri, 16 Jun 2023 17:18:38 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> src/java.base/share/classes/sun/util/locale/BaseLocale.java line 175:
>> 
>>> 173:                             LocaleUtils.toLowerString(b.getLanguage()).intern(),
>>> 174:                             LocaleUtils.toTitleString(b.getScript()).intern(),
>>> 175:                             LocaleUtils.toUpperString(b.getRegion()).intern(),
>> 
>> don't lines 147 and 148 above already guarantee the language and region have correct case?
>
> 147,148 are in `getInstance()` and the BaseLocale key here is created with a constructor, which simply copies the passed arguments. So normalization is needed here

perhaps I am missing something, but aren't `language` and `region` being reassigned to the case adjusted values? So the values used to create the "key" BaseLocale instance reflect that case adjustment? (language is again potentially adjusted at line 162 to account for old iso codes, but that never results in the wrong case.)


        language = LocaleUtils.toLowerString(language);
        region = LocaleUtils.toUpperString(region);

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14404#discussion_r1232880865


More information about the i18n-dev mailing list