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

Alan Bateman alanb at openjdk.org
Wed Dec 6 08:16:34 UTC 2023


On Tue, 5 Dec 2023 23:04:55 GMT, Naoto Sato <naoto 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 class initialization 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.

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

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


More information about the i18n-dev mailing list