src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java

Print this page

        

*** 34,44 **** --- 34,46 ---- import java.text.spi.DateFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.NumberFormatProvider; import java.util.Collections; import java.util.HashSet; + import java.util.List; import java.util.Locale; + import java.util.ResourceBundle; import java.util.ServiceLoader; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap;
*** 377,386 **** --- 379,395 ---- } } return localeData; } + @Override + public List<Locale> getCandidateLocales(String baseName, Locale locale) { + return ResourceBundle.Control + .getNoFallbackControl(ResourceBundle.Control.FORMAT_DEFAULT) + .getCandidateLocales(baseName, locale); + } + /** * Returns a list of the installed locales. Currently, this simply returns * the list of locales for which a sun.text.resources.FormatData bundle * exists. This bundle family happens to be the one with the broadest * locale coverage in the JRE.
*** 415,430 **** return tagset; } private static String createSupportedLocaleString(String category) { ! // Directly call English tags, as we know it's in the base module. ! String supportedLocaleString = EnLocaleDataMetaInfo.getSupportedLocaleString(category); // Use ServiceLoader to dynamically acquire installed locales' tags. try { ! String nonENTags = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() { @Override public String run() { String tags = null; for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) { --- 424,439 ---- return tagset; } private static String createSupportedLocaleString(String category) { ! // Directly call Base tags, as we know it's in the base module. ! String supportedLocaleString = BaseLocaleDataMetaInfo.getSupportedLocaleString(category); // Use ServiceLoader to dynamically acquire installed locales' tags. try { ! String nonBaseTags = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() { @Override public String run() { String tags = null; for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
*** 441,452 **** } return tags; } }); ! if (nonENTags != null) { ! supportedLocaleString += " " + nonENTags; } } catch (Exception e) { // catch any exception, and ignore them as if non-EN locales do not exist. } --- 450,461 ---- } return tags; } }); ! if (nonBaseTags != null) { ! supportedLocaleString += " " + nonBaseTags; } } catch (Exception e) { // catch any exception, and ignore them as if non-EN locales do not exist. }
*** 495,500 **** --- 504,527 ---- locales[i] = Locale.forLanguageTag(currentToken); } } return locales; } + + @Override + public boolean isSupportedProviderLocale(Locale locale, Set<String> langtags) { + if (Locale.ROOT.equals(locale)) { + return true; + } + + locale = locale.stripExtensions(); + if (langtags.contains(locale.toLanguageTag())) { + return true; + } + + String oldname = locale.toString().replace('_', '-'); + return langtags.contains(oldname) || + "ja-JP-JP".equals(oldname) || + "th-TH-TH".equals(oldname) || + "no-NO-NY".equals(oldname); + } }