On Fri, 27 Jan 2023 21:48:26 GMT, Justin Lu <j...@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

Reply via email to