changeset 14437:46891039e911

Merge
author mchung
date Thu, 12 Nov 2015 15:31:31 -0800
parents 30cae8145c33
children 52814ae373b7
files make/gensrc/GensrcModuleLoaderMap.gmk src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java
diffstat 2 files changed, 47 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/make/gensrc/GensrcModuleLoaderMap.gmk	Wed Nov 11 15:50:26 2015 -0800
+++ b/make/gensrc/GensrcModuleLoaderMap.gmk	Thu Nov 12 15:31:31 2015 -0800
@@ -52,6 +52,7 @@
     jdk.sctp \
     jdk.security.auth \
     jdk.security.jgss \
+    jdk.vm.ci \
     #
 
 # to be deprivileged
--- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Wed Nov 11 15:50:26 2015 -0800
+++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Thu Nov 12 15:31:31 2015 -0800
@@ -67,20 +67,25 @@
     }
 
     public CLDRLocaleProviderAdapter() {
-        LocaleDataMetaInfo mi = null;
+        LocaleDataMetaInfo nbmi = null;
+
         try {
-            mi = AccessController.doPrivileged((PrivilegedExceptionAction<LocaleDataMetaInfo>) () -> {
-                for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
-                    if (ldmi.getType() == LocaleProviderAdapter.Type.CLDR) {
-                        return ldmi;
+            nbmi = AccessController.doPrivileged(new PrivilegedExceptionAction<LocaleDataMetaInfo>() {
+                @Override
+                public LocaleDataMetaInfo run() {
+                    for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
+                        if (ldmi.getType() == LocaleProviderAdapter.Type.CLDR) {
+                            return ldmi;
+                        }
                     }
+                    return null;
                 }
-                return null;
             });
         }  catch (Exception e) {
             // Catch any exception, and continue as if only CLDR's base locales exist.
         }
-        this.nonBaseMetaInfo = mi;
+
+        nonBaseMetaInfo = nbmi;
     }
 
     /**
@@ -104,29 +109,40 @@
 
     @Override
     public Locale[] getAvailableLocales() {
-        return createLanguageTagSet("AvailableLocales")
-                   .stream().map(tag -> Locale.forLanguageTag(tag))
-                            .toArray(Locale[]::new);
+        Set<String> all = createLanguageTagSet("AvailableLocales");
+        Locale[] locs = new Locale[all.size()];
+        int index = 0;
+        for (String tag : all) {
+            locs[index++] = Locale.forLanguageTag(tag);
+        }
+        return locs;
     }
 
     @Override
     protected Set<String> createLanguageTagSet(String category) {
-        Set<String> tagset = new HashSet<>();
         // Directly call Base tags, as we know it's in the base module.
-        addTags(baseMetaInfo.availableLanguageTags(category), tagset);
+        String supportedLocaleString = baseMetaInfo.availableLanguageTags(category);
+        String nonBaseTags = null;
+
         if (nonBaseMetaInfo != null) {
-            addTags(nonBaseMetaInfo.availableLanguageTags(category), tagset);
+            nonBaseTags = nonBaseMetaInfo.availableLanguageTags(category);
         }
-        return tagset.isEmpty() ? Collections.emptySet() : tagset;
-    }
-
-    private static void addTags(String tags, Set<String> tagset) {
-        if (tags != null) {
-            StringTokenizer tokens = new StringTokenizer(tags);
-            while (tokens.hasMoreTokens()) {
-                tagset.add(tokens.nextToken());
+        if (nonBaseTags != null) {
+            if (supportedLocaleString != null) {
+                supportedLocaleString += " " + nonBaseTags;
+            } else {
+                supportedLocaleString = nonBaseTags;
             }
         }
+        if (supportedLocaleString == null) {
+            return Collections.emptySet();
+        }
+        Set<String> tagset = new HashSet<>();
+        StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
+        while (tokens.hasMoreTokens()) {
+            tagset.add(tokens.nextToken());
+        }
+        return tagset;
     }
 
     // Implementation of ResourceBundleBasedAdapter
@@ -138,18 +154,16 @@
 
     private List<Locale> applyParentLocales(String baseName, List<Locale> candidates) {
         // check irregular parents
-        int size = candidates.size();
-        for (int i = 0; i < size; i++) {
+        for (int i = 0; i < candidates.size(); i++) {
             Locale l = candidates.get(i);
-            if (l.equals(Locale.ROOT)) {
-                continue;
-            }
-            Locale p = parentLocalesMap.get(l);
-            if (Objects.nonNull(p) &&
-                !candidates.get(i+1).equals(p)) {
-                List<Locale> applied = candidates.subList(0, i+1);
-                applied.addAll(applyParentLocales(baseName, super.getCandidateLocales(baseName, p)));
-                return applied;
+            if (!l.equals(Locale.ROOT)) {
+                Locale p = getParentLocale(l);
+                if (p != null &&
+                    !candidates.get(i+1).equals(p)) {
+                    List<Locale> applied = candidates.subList(0, i+1);
+                    applied.addAll(applyParentLocales(baseName, super.getCandidateLocales(baseName, p)));
+                    return applied;
+                }
             }
         }