On Thu, 5 Jun 2025 11:50:01 GMT, Johannes Döbler <d...@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. > > src/java.base/share/classes/java/util/Locale.java line 1269: > >> 1267: public static String[] getISOCountries() { >> 1268: String[] countries = ISO_3166_1_ALPHA2.get(); >> 1269: return Arrays.copyOf(countries, countries.length); > > what about `return ISO_3166_1_ALPHA2.get().clone();` `clone` is more concise, but I think I prefer the explicitness of `copyOf` here. > src/java.base/share/classes/java/util/Locale.java line 2578: > >> 2576: return Set.of(LocaleISOData.ISO3166_3); >> 2577: } >> 2578: }); > > What about moving these four stable suppliers and `getISO2Table` to > LocaleISOData to shrink size of Locale.java? I like this suggestion, we can also move `getISO3Code` in addition to those you mentioned, and have all ISO resources and methods come from LocaleISOData. @naotoj, would you be in favor of this? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25646#discussion_r2129762095 PR Review Comment: https://git.openjdk.org/jdk/pull/25646#discussion_r2129762038