--- old/src/java.base/share/classes/sun/util/resources/LocaleData.java 2015-06-04 14:16:20.384623389 -0700 +++ new/src/java.base/share/classes/sun/util/resources/LocaleData.java 2015-06-04 14:16:20.067618169 -0700 @@ -51,6 +51,7 @@ import java.util.Set; import sun.util.locale.provider.JRELocaleProviderAdapter; import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.ResourceBundleBasedAdapter; import static sun.util.locale.provider.LocaleProviderAdapter.Type.CLDR; import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE; @@ -204,17 +205,20 @@ * @exception NullPointerException if baseName or locale is null. */ @Override - public List getCandidateLocales(String baseName, Locale locale) { - List candidates = super.getCandidateLocales(baseName, locale); + public List getCandidateLocales(String baseName, Locale locale) { + LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); + List candidates = adapter instanceof ResourceBundleBasedAdapter ? + ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) : + super.getCandidateLocales(baseName, locale); + // Weed out Locales which are known to have no resource bundles int lastDot = baseName.lastIndexOf('.'); String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName; - LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; - LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); Set langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category); if (!langtags.isEmpty()) { for (Iterator itr = candidates.iterator(); itr.hasNext();) { - if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) { + if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) { itr.remove(); } } @@ -247,17 +251,18 @@ private static final String DOTCLDR = ".cldr"; /** - * Changes baseName to its per-language package name and + * Changes baseName to its per-language/country package name and * calls the super class implementation. For example, * if the baseName is "sun.text.resources.FormatData" and locale is ja_JP, - * the baseName is changed to "sun.text.resources.ja.FormatData". If + * the baseName is changed to "sun.text.resources.ja.JP.FormatData". If * baseName contains "cldr", such as "sun.text.resources.cldr.FormatData", - * the name is changed to "sun.text.resources.cldr.jp.FormatData". + * the name is changed to "sun.text.resources.cldr.ja.JP.FormatData". */ @Override public String toBundleName(String baseName, Locale locale) { String newBaseName = baseName; String lang = locale.getLanguage(); + String ctry = locale.getCountry(); if (lang.length() > 0) { if (baseName.startsWith(JRE.getUtilResourcesPackage()) || baseName.startsWith(JRE.getTextResourcesPackage())) { @@ -268,7 +273,8 @@ if (baseName.indexOf(DOTCLDR, index) > 0) { index += DOTCLDR.length(); } - newBaseName = baseName.substring(0, index + 1) + lang + ctry = (ctry.length() == 2) ? ("." + ctry) : ""; + newBaseName = baseName.substring(0, index + 1) + lang + ctry + baseName.substring(index); } }