Print this page
rev 5994 : imported patch 8001205

Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java
          +++ new/src/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java
↓ open down ↓ 146 lines elided ↑ open up ↑
 147  147          }
 148  148  
 149  149          // Add the Host Locale Data Adapter implementation, if needed.
 150  150          lda =  LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.HOST);
 151  151          if (lda != null) {
 152  152              provider = lda.getLocaleServiceProvider(c);
 153  153              if (provider != null) {
 154  154                  providers.putIfAbsent(LocaleProviderAdapter.Type.HOST, provider);
 155  155              }
 156  156          }
      157 +
      158 +        // Add the Fallback Locale Data Adapter implementation, if needed.
      159 +        lda =  LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.FALLBACK);
      160 +        if (lda != null) {
      161 +            provider = lda.getLocaleServiceProvider(c);
      162 +            if (provider != null) {
      163 +                providers.putIfAbsent(LocaleProviderAdapter.Type.FALLBACK, provider);
      164 +            }
      165 +        }
 157  166      }
 158  167  
 159  168      static void config(Class<? extends Object> caller, String message) {
 160  169          PlatformLogger logger = PlatformLogger.getLogger(caller.getCanonicalName());
 161  170          logger.config(message);
 162  171      }
 163  172  
 164  173      /**
 165  174       * Lazy loaded set of available locales.
 166  175       * Loading all locales is a very long operation.
↓ open down ↓ 6 lines elided ↑ open up ↑
 173  182          static final Locale[] allAvailableLocales;
 174  183  
 175  184          static {
 176  185              Set<Locale> all = new HashSet<>();
 177  186              for (Class<? extends LocaleServiceProvider> c : spiClasses) {
 178  187                  LocaleServiceProviderPool pool =
 179  188                      LocaleServiceProviderPool.getPool(c);
 180  189                  all.addAll(pool.getAvailableLocaleList());
 181  190              }
 182  191  
      192 +            // Remove Locale.ROOT for the compatibility.
      193 +            all.remove(Locale.ROOT);
      194 +
 183  195              allAvailableLocales = all.toArray(new Locale[0]);
 184  196          }
 185  197  
 186  198          // No instantiation
 187  199          private AllAvailableLocales() {
 188  200          }
 189  201      }
 190  202  
 191  203      /**
 192  204       * Returns an array of available locales for all the provider classes.
↓ open down ↓ 8 lines elided ↑ open up ↑
 201  213  
 202  214      /**
 203  215       * Returns an array of available locales.  This array is a
 204  216       * merged array of all the locales that are provided by each
 205  217       * provider, including the JRE.
 206  218       *
 207  219       * @return an array of the available locales
 208  220       */
 209  221      public Locale[] getAvailableLocales() {
 210  222          Set<Locale> locList = getAvailableLocaleList();
      223 +        // Remove Locale.ROOT for the compatibility.
      224 +        locList.remove(Locale.ROOT);
 211  225          Locale[] tmp = new Locale[locList.size()];
 212  226          locList.toArray(tmp);
 213  227          return tmp;
 214  228      }
 215  229  
 216  230      private synchronized Set<Locale> getAvailableLocaleList() {
 217  231          if (availableLocales == null) {
 218  232              availableLocales = new HashSet<>();
 219  233              for (LocaleServiceProvider lsp : providers.values()) {
 220  234                  Locale[] locales = lsp.getAvailableLocales();
 221  235                  for (Locale locale: locales) {
 222  236                      availableLocales.add(getLookupLocale(locale));
 223  237                  }
 224  238              }
 225      -
 226      -            // Remove Locale.ROOT for the compatibility.
 227      -            availableLocales.remove(Locale.ROOT);
 228  239          }
 229  240  
 230  241          return availableLocales;
 231  242      }
 232  243  
 233  244      /**
 234  245       * Returns whether any provider for this locale sensitive
 235  246       * service is available or not, excluding JRE's one.
 236  247       *
 237  248       * @return true if any provider (other than JRE) is available
↓ open down ↓ 193 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX