288 * |
287 * |
289 * This variable would be better named "cache", but we keep the old |
288 * This variable would be better named "cache", but we keep the old |
290 * name for compatibility with some workarounds for bug 4212439. |
289 * name for compatibility with some workarounds for bug 4212439. |
291 */ |
290 */ |
292 private static final ConcurrentMap<CacheKey, BundleReference> cacheList |
291 private static final ConcurrentMap<CacheKey, BundleReference> cacheList |
293 = new ConcurrentHashMap<CacheKey, BundleReference>(INITIAL_CACHE_SIZE); |
292 = new ConcurrentHashMap<>(INITIAL_CACHE_SIZE); |
294 |
293 |
295 /** |
294 /** |
296 * Queue for reference objects referring to class loaders or bundles. |
295 * Queue for reference objects referring to class loaders or bundles. |
297 */ |
296 */ |
298 private static final ReferenceQueue referenceQueue = new ReferenceQueue(); |
297 private static final ReferenceQueue referenceQueue = new ReferenceQueue(); |
1781 */ |
1780 */ |
1782 protected Set<String> handleKeySet() { |
1781 protected Set<String> handleKeySet() { |
1783 if (keySet == null) { |
1782 if (keySet == null) { |
1784 synchronized (this) { |
1783 synchronized (this) { |
1785 if (keySet == null) { |
1784 if (keySet == null) { |
1786 Set<String> keys = new HashSet<String>(); |
1785 Set<String> keys = new HashSet<>(); |
1787 Enumeration<String> enumKeys = getKeys(); |
1786 Enumeration<String> enumKeys = getKeys(); |
1788 while (enumKeys.hasMoreElements()) { |
1787 while (enumKeys.hasMoreElements()) { |
1789 String key = enumKeys.nextElement(); |
1788 String key = enumKeys.nextElement(); |
1790 if (handleGetObject(key) != null) { |
1789 if (handleGetObject(key) != null) { |
1791 keys.add(key); |
1790 keys.add(key); |
2325 } |
2324 } |
2326 } |
2325 } |
2327 if (language.equals("nb") || isNorwegianBokmal) { |
2326 if (language.equals("nb") || isNorwegianBokmal) { |
2328 List<Locale> tmpList = getDefaultList("nb", script, region, variant); |
2327 List<Locale> tmpList = getDefaultList("nb", script, region, variant); |
2329 // Insert a locale replacing "nb" with "no" for every list entry |
2328 // Insert a locale replacing "nb" with "no" for every list entry |
2330 List<Locale> bokmalList = new LinkedList<Locale>(); |
2329 List<Locale> bokmalList = new LinkedList<>(); |
2331 for (Locale l : tmpList) { |
2330 for (Locale l : tmpList) { |
2332 bokmalList.add(l); |
2331 bokmalList.add(l); |
2333 if (l.getLanguage().length() == 0) { |
2332 if (l.getLanguage().length() == 0) { |
2334 break; |
2333 break; |
2335 } |
2334 } |
2336 bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), |
2335 bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), |
2337 l.getVariant(), LocaleExtensions.EMPTY_EXTENSIONS)); |
2336 l.getVariant(), null)); |
2338 } |
2337 } |
2339 return bokmalList; |
2338 return bokmalList; |
2340 } else if (language.equals("nn") || isNorwegianNynorsk) { |
2339 } else if (language.equals("nn") || isNorwegianNynorsk) { |
2341 // Insert no_NO_NY, no_NO, no after nn |
2340 // Insert no_NO_NY, no_NO, no after nn |
2342 List<Locale> nynorskList = getDefaultList("nn", script, region, variant); |
2341 List<Locale> nynorskList = getDefaultList("nn", script, region, variant); |
2372 |
2371 |
2373 private static List<Locale> getDefaultList(String language, String script, String region, String variant) { |
2372 private static List<Locale> getDefaultList(String language, String script, String region, String variant) { |
2374 List<String> variants = null; |
2373 List<String> variants = null; |
2375 |
2374 |
2376 if (variant.length() > 0) { |
2375 if (variant.length() > 0) { |
2377 variants = new LinkedList<String>(); |
2376 variants = new LinkedList<>(); |
2378 int idx = variant.length(); |
2377 int idx = variant.length(); |
2379 while (idx != -1) { |
2378 while (idx != -1) { |
2380 variants.add(variant.substring(0, idx)); |
2379 variants.add(variant.substring(0, idx)); |
2381 idx = variant.lastIndexOf('_', --idx); |
2380 idx = variant.lastIndexOf('_', --idx); |
2382 } |
2381 } |
2383 } |
2382 } |
2384 |
2383 |
2385 LinkedList<Locale> list = new LinkedList<Locale>(); |
2384 List<Locale> list = new LinkedList<>(); |
2386 |
2385 |
2387 if (variants != null) { |
2386 if (variants != null) { |
2388 for (String v : variants) { |
2387 for (String v : variants) { |
2389 list.add(Locale.getInstance(language, script, region, v, LocaleExtensions.EMPTY_EXTENSIONS)); |
2388 list.add(Locale.getInstance(language, script, region, v, null)); |
2390 } |
2389 } |
2391 } |
2390 } |
2392 if (region.length() > 0) { |
2391 if (region.length() > 0) { |
2393 list.add(Locale.getInstance(language, script, region, "", LocaleExtensions.EMPTY_EXTENSIONS)); |
2392 list.add(Locale.getInstance(language, script, region, "", null)); |
2394 } |
2393 } |
2395 if (script.length() > 0) { |
2394 if (script.length() > 0) { |
2396 list.add(Locale.getInstance(language, script, "", "", LocaleExtensions.EMPTY_EXTENSIONS)); |
2395 list.add(Locale.getInstance(language, script, "", "", null)); |
2397 |
2396 |
2398 // With script, after truncating variant, region and script, |
2397 // With script, after truncating variant, region and script, |
2399 // start over without script. |
2398 // start over without script. |
2400 if (variants != null) { |
2399 if (variants != null) { |
2401 for (String v : variants) { |
2400 for (String v : variants) { |
2402 list.add(Locale.getInstance(language, "", region, v, LocaleExtensions.EMPTY_EXTENSIONS)); |
2401 list.add(Locale.getInstance(language, "", region, v, null)); |
2403 } |
2402 } |
2404 } |
2403 } |
2405 if (region.length() > 0) { |
2404 if (region.length() > 0) { |
2406 list.add(Locale.getInstance(language, "", region, "", LocaleExtensions.EMPTY_EXTENSIONS)); |
2405 list.add(Locale.getInstance(language, "", region, "", null)); |
2407 } |
2406 } |
2408 } |
2407 } |
2409 if (language.length() > 0) { |
2408 if (language.length() > 0) { |
2410 list.add(Locale.getInstance(language, "", "", "", LocaleExtensions.EMPTY_EXTENSIONS)); |
2409 list.add(Locale.getInstance(language, "", "", "", null)); |
2411 } |
2410 } |
2412 // Add root locale at the end |
2411 // Add root locale at the end |
2413 list.add(Locale.ROOT); |
2412 list.add(Locale.ROOT); |
2414 |
2413 |
2415 return list; |
2414 return list; |