<i18n dev> RFR: 8358426: Improve lazy computation in Locale

Per Minborg pminborg at openjdk.org
Thu Jun 5 10:57:50 UTC 2025


On Thu, 5 Jun 2025 00:18:34 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Please review this PR which improves occurrences of lazy computation in `Locale` and `BaseLocale`.
>> 
>> Existing lazy initialization strategies such as CHM, static nested class, and local inner class are replaced with Stable Values.
>> 
>> Lambda usage is intentionally avoided in this change during `Locale` creation and in static fields due to potential startup performance degradation as noted by [JDK-8331932](https://bugs.openjdk.org/browse/JDK-8331932).
>> 
>> Rather than convert `iso3166CodesMap` to a Stable Map, each ISO 3166 resource is represented as a SV. Also, I did not think it was necessary to maintain a SV for _both_ the array and set of ISO3166-1 alpha-2 codes.
>
> Looks correct. Note we have a separate effort #25040 to avoid anonymous supplier classes, don't know if @minborg wishes locale to migrate to that one directly or remain on the more high-level SV.

Looks good! As @liach mentioned, there is an even better way coming, but I think it's good to do this update anyway. Here is a similar one that I am working on: https://github.com/openjdk/jdk/pull/25630

So, once we have stable field updaters, it will be almost trivial to update the code in this PR.

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

PR Comment: https://git.openjdk.org/jdk/pull/25646#issuecomment-2943716752


More information about the i18n-dev mailing list