On Fri, 25 Mar 2022 01:56:33 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java >> line 375: >> >>> 373: (locale.getLanguage().isEmpty() ? "und" : >>> locale.getLanguage()) + >>> 374: (locale.getCountry().isEmpty() ? "" : "-" + >>> locale.getCountry()) + >>> 375: (locale.getVariant().isEmpty() ? "" : >>> "-x-lvariant-" + locale.getVariant())); >> >> It seems like this snippet (and ones very similar to it) are repeated >> several times throughout the JDK code as replacements for the two- and >> three-arg constructors. This seems like a fair increase in complexity, and >> the use of "und" and "-x-lvariant-" are quite non-obvious. Would we >> recommend that third party code that uses the Locale constructors replace >> them with this snippet? Is there something better that we can provide? > > True. One solution could be to expose `Locale.getInstance()`, which is > currently a package-private static method, for this purpose. Though that > means promoting `ill-formed` locale objects which defy some part of the > deprecation cause. Introduced a new `Locale.of(String...)` method. ------------- PR: https://git.openjdk.java.net/jdk/pull/7947