<i18n dev> RFR: 8282319: java.util.Locale method to stream available Locales

Sergey Tsypanov stsypanov at openjdk.org
Thu Feb 23 08:48:47 UTC 2023


On Fri, 27 Jan 2023 21:48:26 GMT, Justin Lu <jlu at openjdk.org> wrote:

> This PR proposes introducing a new method to Locale which returns Stream<Locale>
> 
> It involves adding an additional method to _LocaleServiceProviderPool_ that returns Stream, which _Locale_ can call.
> 
> `LocaleServiceProviderPool.streamAllAvaliableLocales()` does not need a defensive copy of `AllAvailableLocales.allAvailableLocales` unlike `LocaleServiceProviderPool.getAllAvaliableLocales()` as the array is hidden by the Stream.

src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java line 160:

> 158:      */
> 159:     public static Stream<Locale> streamAvailableLocales() {
> 160:         return AllAvailableLocales.AvailableLocalesSet.stream();

I think we could use `Stream.of(AllAvailableLocales.availableLocalesArray)` here and drop set field.

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

PR: https://git.openjdk.org/jdk/pull/12269


More information about the i18n-dev mailing list