<i18n dev> RFR: 8321206: Make Locale related system properties static properties

Naoto Sato naoto at openjdk.org
Wed Dec 6 18:08:38 UTC 2023


On Wed, 6 Dec 2023 08:14:05 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Currently, Locale-related system properties, such as `user.language` or `user.country`, are initialized when the `Locale` class is loaded. Making them static properties is safer than relying on the `Locale` class loading timing, which could potentially be changed depending on the implementation.
>
> src/java.base/share/classes/java/util/Locale.java line 1099:
> 
>> 1097:             StaticProperty.userCountry(category.ordinal() + 1),
>> 1098:             StaticProperty.userVariant(category.ordinal() + 1),
>> 1099:             getDefaultExtensions(StaticProperty.userExtensions(category.ordinal() + 1))
> 
> I suspect this would be more readable, and maintainable, if you add non-public languageKey/scriptKey/countryKey/variantKey methods to Locale.Category. That would change this to getInstance(category.languageKey(), ...) so no sight of the ordinal at the use-site.

Right. Will change it in the next iteration

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16986#discussion_r1417769586


More information about the i18n-dev mailing list