--- old/src/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java Mon Nov 5 14:14:26 2012 +++ new/src/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java Mon Nov 5 14:14:23 2012 @@ -26,6 +26,7 @@ package sun.util.locale.provider; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.IllformedLocaleException; @@ -177,7 +178,7 @@ for (Class c : spiClasses) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(c); - all.addAll(pool.getAvailableLocaleList()); + all.addAll(pool.getAvailableLocaleSet()); } allAvailableLocales = all.toArray(new Locale[0]); @@ -202,18 +203,28 @@ /** * Returns an array of available locales. This array is a * merged array of all the locales that are provided by each - * provider, including the JRE. + * provider, including the JRE's FormatData locales. * * @return an array of the available locales */ public Locale[] getAvailableLocales() { - Set locList = getAvailableLocaleList(); + Set locList = new HashSet<>(); + locList.addAll(getAvailableLocaleSet()); + // Make sure it all contains JRE's FormatData locales for compatibility. + locList.addAll(Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales())); Locale[] tmp = new Locale[locList.size()]; locList.toArray(tmp); return tmp; } - private synchronized Set getAvailableLocaleList() { + /** + * Returns the union of locale sets that are available from + * each service provider. This method does NOT return the + * defensive copy. + * + * @return a set of available locales + */ + private synchronized Set getAvailableLocaleSet() { if (availableLocales == null) { availableLocales = new HashSet<>(); for (LocaleServiceProvider lsp : providers.values()) { @@ -222,9 +233,6 @@ availableLocales.add(getLookupLocale(locale)); } } - - // Remove Locale.ROOT for the compatibility. - availableLocales.remove(Locale.ROOT); } return availableLocales; @@ -295,7 +303,7 @@ List lookupLocales = getLookupLocales(locale); - Set available = getAvailableLocaleList(); + Set available = getAvailableLocaleSet(); for (Locale current : lookupLocales) { if (available.contains(current)) { S providersObj;