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

Justin Lu jlu at openjdk.org
Thu Feb 23 08:48:48 UTC 2023


On Mon, 30 Jan 2023 07:11:57 GMT, Sergey Tsypanov <stsypanov 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.

Yes you're right, I had misinterpreted the original bug description. Set is not required, and in fact the array should be streamed directly as you said.

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

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


More information about the i18n-dev mailing list