--- old/make/CreateJars.gmk 2014-08-22 11:18:14.925721071 -0700 +++ new/make/CreateJars.gmk 2014-08-22 11:18:14.626716652 -0700 @@ -76,13 +76,24 @@ iw ja ko lt lv mk ms mt nl no pl pt ro ru sk sl sq sr sv \ th tr uk vi zh -LOCALEDATA_INCLUDES := $(addprefix sun/text/resources/, $(LOCALEDATA_INCLUDE_LOCALES)) \ +LOCALEDATA_INCLUDES := sun/util/locale/provider/JRENonENLocaleDataMetaInfo.class +LOCALEDATA_INCLUDES += $(addprefix sun/text/resources/, $(LOCALEDATA_INCLUDE_LOCALES)) \ $(addprefix sun/util/resources/, $(LOCALEDATA_INCLUDE_LOCALES)) -$(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/modules/jdk.localedata, \ +LOCALEDATA_SERVICES_DIR := $(IMAGES_OUTPUTDIR)/localemetainfo + +LOCALEDATA_METAINF_SERVICES := $(LOCALEDATA_SERVICES_DIR)/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo + +$(LOCALEDATA_METAINF_SERVICES): $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/locale/provider/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo + $(install-file) + +$(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR, \ + $(LOCALEDATA_METAINF_SERVICES), \ + SRCS := $(JDK_OUTPUTDIR)/modules/jdk.localedata \ + $(LOCALEDATA_SERVICES_DIR), \ SUFFIXES := .class _dict _th, \ INCLUDES := $(LOCALEDATA_INCLUDES), \ + EXTRA_FILES := META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo, \ JAR := $(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar, \ SKIP_METAINF := true)) @@ -210,6 +221,8 @@ sun/tools/tree \ sun/tools/util \ sun/util/cldr/CLDRLocaleDataMetaInfo.class \ + sun/util/locale/provider/JRENonENLocaleDataMetaInfo.class \ + META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo \ sun/util/resources/cldr \ $(LOCALEDATA_INCLUDES) \ com/oracle/jrockit/jfr \ @@ -429,13 +442,23 @@ CLDRDATA_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/cldrdata.jar -$(eval $(call SetupArchive,BUILD_CLDRDATA_JAR, , \ +CLDR_SERVICES_DIR := $(IMAGES_OUTPUTDIR)/cldrmetainfo + +CLDR_METAINF_SERVICES := $(CLDR_SERVICES_DIR)/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo + +$(CLDR_METAINF_SERVICES): $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/cldr/sun.util.locale.provider.LocaleDataMetaInfo + $(install-file) + +$(eval $(call SetupArchive,BUILD_CLDRDATA_JAR, \ + $(CLDR_METAINF_SERVICES), \ SRCS := $(JDK_OUTPUTDIR)/modules/jdk.localedata \ - $(JDK_OUTPUTDIR)/modules/java.base, \ + $(JDK_OUTPUTDIR)/modules/java.base \ + $(CLDR_SERVICES_DIR), \ SUFFIXES := .class, \ INCLUDES := sun/text/resources/cldr \ sun/util/cldr/CLDRLocaleDataMetaInfo.class \ sun/util/resources/cldr, \ + EXTRA_FILES := META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo, \ JAR := $(CLDRDATA_JAR_DST), \ EXTRA_MANIFEST_ATTR := CLDR-Version: $(CLDRVERSION), \ SKIP_METAINF := true)) --- old/make/gensrc/Gensrc-java.base.gmk 2014-08-22 11:18:16.557745189 -0700 +++ new/make/gensrc/Gensrc-java.base.gmk 2014-08-22 11:18:16.164739382 -0700 @@ -29,7 +29,7 @@ include GensrcProperties.gmk GENSRC_JAVA_BASE += $(GENSRC_PROPERTIES) -include GensrcLocaleDataMetaInfo.gmk +include GensrcCoreResourceBundleControl.gmk include GensrcCharacterData.gmk include GensrcMisc.gmk include GensrcCharsetMapping.gmk --- old/make/src/classes/build/tools/cldrconverter/CLDRConverter.java 2014-08-22 11:18:18.163768923 -0700 +++ new/make/src/classes/build/tools/cldrconverter/CLDRConverter.java 2014-08-22 11:18:17.823763897 -0700 @@ -431,7 +431,7 @@ allLocales.addAll(metaInfo.get("LocaleNames")); allLocales.addAll(metaInfo.get("CalendarData")); allLocales.addAll(metaInfo.get("FormatData")); - metaInfo.put("All", allLocales); + metaInfo.put("AvailableLocales", allLocales); } bundleGenerator.generateMetaInfo(metaInfo); --- old/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java 2014-08-22 11:18:19.835793632 -0700 +++ new/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java 2014-08-22 11:18:19.528789094 -0700 @@ -159,8 +159,10 @@ out.println(CopyrightHeaders.getOpenJDKCopyright()); out.println("package sun.util.cldr;\n\n" - + "import java.util.ListResourceBundle;\n"); - out.printf("public class %s extends ListResourceBundle {\n", METAINFO_CLASS); + + "import java.util.ListResourceBundle;\n" + + "import sun.util.locale.provider.LocaleProviderAdapter;\n" + + "import sun.util.locale.provider.LocaleDataMetaInfo;\n"); + out.printf("public class %s extends ListResourceBundle implements LocaleDataMetaInfo {\n", METAINFO_CLASS); out.println(" @Override\n" + " protected final Object[][] getContents() {\n" + " final Object[][] data = new Object[][] {"); @@ -168,7 +170,15 @@ out.printf(" { \"%s\",\n", key); out.printf(" \"%s\" },\n", toLocaleList(metaInfo.get(key))); } - out.println(" };\n return data;\n }\n}"); + out.println(" };\n return data;\n }\n\n"); + + out.println(" public LocaleProviderAdapter.Type getType() {\n" + + " return LocaleProviderAdapter.Type.CLDR;\n" + + " }\n\n"); + + out.println(" public String availableLanguageTags(String category) {\n" + + " return getString(category);\n" + + " };\n}"); } } --- old/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java 2014-08-22 11:18:21.400816759 -0700 +++ new/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java 2014-08-22 11:18:21.049811571 -0700 @@ -25,20 +25,20 @@ package sun.util.cldr; -import java.io.File; import java.security.AccessController; -import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.text.spi.BreakIteratorProvider; import java.text.spi.CollatorProvider; import java.util.Collections; import java.util.HashSet; import java.util.Locale; -import java.util.ResourceBundle; +import java.util.ServiceLoader; import java.util.Set; import java.util.StringTokenizer; -import java.util.spi.TimeZoneNameProvider; import sun.util.locale.provider.JRELocaleProviderAdapter; import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleDataMetaInfo; /** * LocaleProviderAdapter implementation for the CLDR locale data. @@ -47,25 +47,27 @@ * @author Naoto Sato */ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { - private static final String LOCALE_DATA_JAR_NAME = "cldrdata.jar"; + + private LocaleDataMetaInfo metaInfo; public CLDRLocaleProviderAdapter() { - final String sep = File.separator; - String localeDataJar = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.home")) - + sep + "lib" + sep + "ext" + sep + LOCALE_DATA_JAR_NAME; - - // Peek at the installed extension directory to see if the jar file for - // CLDR resources is installed or not. - final File f = new File(localeDataJar); - boolean result = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Boolean run() { - return f.exists(); + try { + metaInfo = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public LocaleDataMetaInfo run() { + for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) { + if (ldmi.getType() == LocaleProviderAdapter.Type.CLDR) { + return ldmi; + } } - }); - if (!result) { + return null; + } + }); + } catch (Exception e) { + // catch any exception, and fail gracefully. + } + + if (metaInfo == null) { throw new UnsupportedOperationException(); } } @@ -91,7 +93,7 @@ @Override public Locale[] getAvailableLocales() { - Set all = createLanguageTagSet("All"); + Set all = createLanguageTagSet("AvailableLocales"); Locale[] locs = new Locale[all.size()]; int index = 0; for (String tag : all) { @@ -102,11 +104,10 @@ @Override protected Set createLanguageTagSet(String category) { - ResourceBundle rb = ResourceBundle.getBundle("sun.util.cldr.CLDRLocaleDataMetaInfo", Locale.ROOT); - if (rb.containsKey(category)) { + String supportedLocaleString = metaInfo.availableLanguageTags(category); + if (supportedLocaleString == null) { return Collections.emptySet(); } - String supportedLocaleString = rb.getString(category); Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); while (tokens.hasMoreTokens()) { --- old/src/java.base/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java 2014-08-22 11:18:23.219843640 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java 2014-08-22 11:18:22.915839148 -0700 @@ -56,7 +56,7 @@ /** * SPI implementations map */ - private ConcurrentMap, LocaleServiceProvider> providersMap = + private final ConcurrentMap, LocaleServiceProvider> providersMap = new ConcurrentHashMap<>(); /** @@ -167,7 +167,6 @@ avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } - availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. @@ -178,7 +177,7 @@ * A dummy locale service provider that indicates there is no * provider available */ - private static NullProvider NULL_PROVIDER = new NullProvider(); + private static final NullProvider NULL_PROVIDER = new NullProvider(); private static class NullProvider extends LocaleServiceProvider { @Override public Locale[] getAvailableLocales() { --- old/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java 2014-08-22 11:18:24.946869161 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java 2014-08-22 11:18:24.592863930 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,11 +48,9 @@ private static final int SENTENCE_INDEX = 3; private final LocaleProviderAdapter.Type type; - private final Set langtags; - public BreakIteratorProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public BreakIteratorProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -64,7 +62,7 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(DateFormatProviderImpl.getLangTags(type)); } /** @@ -181,11 +179,11 @@ @Override public Set getAvailableLanguageTags() { - return langtags; + return DateFormatProviderImpl.getLangTags(type); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); -} + return LocaleProviderAdapter.isSupportedLocale(locale, type, DateFormatProviderImpl.getLangTags(type)); + } } --- old/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java 2014-08-22 11:18:26.841897166 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java 2014-08-22 11:18:26.522892452 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,11 +37,10 @@ */ public class CalendarDataProviderImpl extends CalendarDataProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - public CalendarDataProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public CalendarDataProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } @Override @@ -58,11 +57,18 @@ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } @Override public Set getAvailableLanguageTags() { + return getLangTags(); + } + + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CalendarData"); + } return langtags; } } --- old/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java 2014-08-22 11:18:28.357919568 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java 2014-08-22 11:18:28.056915122 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,11 +41,9 @@ */ public class CalendarNameProviderImpl extends CalendarNameProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; - public CalendarNameProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public CalendarNameProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } @Override @@ -84,7 +82,7 @@ return name; } - private static int[] REST_OF_STYLES = { + private static final int[] REST_OF_STYLES = { SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE, NARROW_FORMAT, NARROW_STANDALONE }; @@ -165,7 +163,7 @@ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(DateFormatProviderImpl.getLangTags(type)); } @Override @@ -192,19 +190,19 @@ return false; } } - if (langtags.contains(locale.toLanguageTag())) { + if (DateFormatProviderImpl.getLangTags(type).contains(locale.toLanguageTag())) { return true; } if (type == LocaleProviderAdapter.Type.JRE) { String oldname = locale.toString().replace('_', '-'); - return langtags.contains(oldname); + return DateFormatProviderImpl.getLangTags(type).contains(oldname); } return false; } @Override public Set getAvailableLanguageTags() { - return langtags; + return DateFormatProviderImpl.getLangTags(type); } private boolean hasDuplicates(String[] strings) { --- old/src/java.base/share/classes/sun/util/locale/provider/CalendarProviderImpl.java 2014-08-22 11:18:30.088945149 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/CalendarProviderImpl.java 2014-08-22 11:18:29.791940762 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package sun.util.locale.provider; import java.util.Calendar; -import java.util.Calendar.Builder; import java.util.Locale; import java.util.Set; import java.util.TimeZone; @@ -40,11 +39,10 @@ */ public class CalendarProviderImpl extends CalendarProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - public CalendarProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public CalendarProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -56,7 +54,7 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } @Override @@ -90,6 +88,13 @@ @Override public Set getAvailableLanguageTags() { + return getLangTags(); + } + + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CalendarData"); + } return langtags; } } --- old/src/java.base/share/classes/sun/util/locale/provider/CollatorProviderImpl.java 2014-08-22 11:18:31.708969091 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/CollatorProviderImpl.java 2014-08-22 11:18:31.406964629 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,11 +54,10 @@ */ public class CollatorProviderImpl extends CollatorProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - public CollatorProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public CollatorProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -70,12 +69,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags()); } /** @@ -126,6 +125,13 @@ @Override public Set getAvailableLanguageTags() { + return getLangTags(); + } + + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CollationData"); + } return langtags; } } --- old/src/java.base/share/classes/sun/util/locale/provider/CurrencyNameProviderImpl.java 2014-08-22 11:18:33.291992486 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/CurrencyNameProviderImpl.java 2014-08-22 11:18:32.936987238 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,16 +40,15 @@ public class CurrencyNameProviderImpl extends CurrencyNameProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - public CurrencyNameProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public CurrencyNameProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } @Override public Set getAvailableLanguageTags() { - return langtags; + return getLangTags(); } /** @@ -61,7 +60,7 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } /** @@ -121,4 +120,11 @@ return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCurrencyName(key); } + + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CurrencyNames"); + } + return langtags; + } } --- old/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java 2014-08-22 11:18:34.831015228 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java 2014-08-22 11:18:34.547011032 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,11 +42,10 @@ */ public class DateFormatProviderImpl extends DateFormatProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private static Set langtags; - public DateFormatProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public DateFormatProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -58,12 +57,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags(type)); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags(type)); } /** @@ -164,6 +163,17 @@ @Override public Set getAvailableLanguageTags() { + return getLangTags(type); + } + + /** + * Available language tags for FormatData resources. Shared with other "format" + * provider implementations. + * */ + static Set getLangTags(LocaleProviderAdapter.Type t) { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(t)).getLanguageTagSet("FormatData"); + } return langtags; } } --- old/src/java.base/share/classes/sun/util/locale/provider/DateFormatSymbolsProviderImpl.java 2014-08-22 11:18:36.380038121 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/DateFormatSymbolsProviderImpl.java 2014-08-22 11:18:36.082033715 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,9 @@ */ public class DateFormatSymbolsProviderImpl extends DateFormatSymbolsProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; - public DateFormatSymbolsProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public DateFormatSymbolsProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -55,12 +53,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(DateFormatProviderImpl.getLangTags(type)); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, DateFormatProviderImpl.getLangTags(type)); } /** @@ -87,6 +85,6 @@ @Override public Set getAvailableLanguageTags() { - return langtags; + return DateFormatProviderImpl.getLangTags(type); } } --- old/src/java.base/share/classes/sun/util/locale/provider/DecimalFormatSymbolsProviderImpl.java 2014-08-22 11:18:38.080063243 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/DecimalFormatSymbolsProviderImpl.java 2014-08-22 11:18:37.741058234 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,9 @@ */ public class DecimalFormatSymbolsProviderImpl extends DecimalFormatSymbolsProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; - public DecimalFormatSymbolsProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public DecimalFormatSymbolsProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -55,12 +53,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(DateFormatProviderImpl.getLangTags(type)); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, DateFormatProviderImpl.getLangTags(type)); } /** @@ -87,6 +85,6 @@ @Override public Set getAvailableLanguageTags() { - return langtags; + return DateFormatProviderImpl.getLangTags(type); } } --- old/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java 2014-08-22 11:18:39.624086060 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java 2014-08-22 11:18:39.313081466 -0700 @@ -25,9 +25,9 @@ package sun.util.locale.provider; -import java.io.File; import java.security.AccessController; -import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.text.spi.BreakIteratorProvider; import java.text.spi.CollatorProvider; import java.text.spi.DateFormatProvider; @@ -37,6 +37,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Locale; +import java.util.ServiceLoader; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; @@ -58,8 +59,6 @@ */ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements ResourceBundleBasedAdapter { - private static final String LOCALE_DATA_JAR_NAME = "localedata.jar"; - private final ConcurrentMap> langtagSets = new ConcurrentHashMap<>(); @@ -134,8 +133,7 @@ @Override public BreakIteratorProvider getBreakIteratorProvider() { if (breakIteratorProvider == null) { - BreakIteratorProvider provider = new BreakIteratorProviderImpl(getAdapterType(), - getLanguageTagSet("FormatData")); + BreakIteratorProvider provider = new BreakIteratorProviderImpl(getAdapterType()); synchronized (this) { if (breakIteratorProvider == null) { breakIteratorProvider = provider; @@ -148,8 +146,7 @@ @Override public CollatorProvider getCollatorProvider() { if (collatorProvider == null) { - CollatorProvider provider = new CollatorProviderImpl(getAdapterType(), - getLanguageTagSet("CollationData")); + CollatorProvider provider = new CollatorProviderImpl(getAdapterType()); synchronized (this) { if (collatorProvider == null) { collatorProvider = provider; @@ -162,8 +159,7 @@ @Override public DateFormatProvider getDateFormatProvider() { if (dateFormatProvider == null) { - DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(), - getLanguageTagSet("FormatData")); + DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType()); synchronized (this) { if (dateFormatProvider == null) { dateFormatProvider = provider; @@ -176,8 +172,7 @@ @Override public DateFormatSymbolsProvider getDateFormatSymbolsProvider() { if (dateFormatSymbolsProvider == null) { - DateFormatSymbolsProvider provider = new DateFormatSymbolsProviderImpl(getAdapterType(), - getLanguageTagSet("FormatData")); + DateFormatSymbolsProvider provider = new DateFormatSymbolsProviderImpl(getAdapterType()); synchronized (this) { if (dateFormatSymbolsProvider == null) { dateFormatSymbolsProvider = provider; @@ -190,7 +185,7 @@ @Override public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() { if (decimalFormatSymbolsProvider == null) { - DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData")); + DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType()); synchronized (this) { if (decimalFormatSymbolsProvider == null) { decimalFormatSymbolsProvider = provider; @@ -203,8 +198,7 @@ @Override public NumberFormatProvider getNumberFormatProvider() { if (numberFormatProvider == null) { - NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(), - getLanguageTagSet("FormatData")); + NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType()); synchronized (this) { if (numberFormatProvider == null) { numberFormatProvider = provider; @@ -220,8 +214,7 @@ @Override public CurrencyNameProvider getCurrencyNameProvider() { if (currencyNameProvider == null) { - CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType(), - getLanguageTagSet("CurrencyNames")); + CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType()); synchronized (this) { if (currencyNameProvider == null) { currencyNameProvider = provider; @@ -234,8 +227,7 @@ @Override public LocaleNameProvider getLocaleNameProvider() { if (localeNameProvider == null) { - LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(), - getLanguageTagSet("LocaleNames")); + LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType()); synchronized (this) { if (localeNameProvider == null) { localeNameProvider = provider; @@ -248,8 +240,7 @@ @Override public TimeZoneNameProvider getTimeZoneNameProvider() { if (timeZoneNameProvider == null) { - TimeZoneNameProvider provider = new TimeZoneNameProviderImpl(getAdapterType(), - getLanguageTagSet("TimeZoneNames")); + TimeZoneNameProvider provider = new TimeZoneNameProviderImpl(getAdapterType()); synchronized (this) { if (timeZoneNameProvider == null) { timeZoneNameProvider = provider; @@ -263,8 +254,7 @@ public CalendarDataProvider getCalendarDataProvider() { if (calendarDataProvider == null) { CalendarDataProvider provider; - provider = new CalendarDataProviderImpl(getAdapterType(), - getLanguageTagSet("CalendarData")); + provider = new CalendarDataProviderImpl(getAdapterType()); synchronized (this) { if (calendarDataProvider == null) { calendarDataProvider = provider; @@ -278,8 +268,7 @@ public CalendarNameProvider getCalendarNameProvider() { if (calendarNameProvider == null) { CalendarNameProvider provider; - provider = new CalendarNameProviderImpl(getAdapterType(), - getLanguageTagSet("FormatData")); + provider = new CalendarNameProviderImpl(getAdapterType()); synchronized (this) { if (calendarNameProvider == null) { calendarNameProvider = provider; @@ -295,8 +284,7 @@ @Override public CalendarProvider getCalendarProvider() { if (calendarProvider == null) { - CalendarProvider provider = new CalendarProviderImpl(getAdapterType(), - getLanguageTagSet("CalendarData")); + CalendarProvider provider = new CalendarProviderImpl(getAdapterType()); synchronized (this) { if (calendarProvider == null) { calendarProvider = provider; @@ -356,24 +344,54 @@ } protected Set createLanguageTagSet(String category) { - String supportedLocaleString = LocaleDataMetaInfo.getSupportedLocaleString(category); + String supportedLocaleString = createSupportedLocaleString(category); if (supportedLocaleString == null) { return Collections.emptySet(); } Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); while (tokens.hasMoreTokens()) { - String token = tokens.nextToken(); - if (token.equals("|")) { - if (isNonENLangSupported()) { - continue; + tagset.add(tokens.nextToken()); + } + + return tagset; + } + + private static String createSupportedLocaleString(String category) { + // Directly call English tags, as we know it's in the base module. + String supportedLocaleString = JREENLocaleDataMetaInfo.getSupportedLocaleString(category); + + // Use ServiceLoader to dynamically acquire installede locales' tags. + try { + String nonENTags = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public String run() { + String tags = null; + for (LocaleDataMetaInfo ldmi : + ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) { + if (ldmi.getType() == LocaleProviderAdapter.Type.JRE) { + String t = ldmi.availableLanguageTags(category); + if (t != null) { + if (tags == null) { + tags = t; + } else { + tags += " " + t; + } + } + } + } + return tags; } - break; + }); + + if (nonENTags != null) { + supportedLocaleString += " " + nonENTags; } - tagset.add(token); + } catch (Exception e) { + // catch any exception, and ignore them as if non-EN locales do not exist. } - return tagset; + return supportedLocaleString; } /** @@ -387,27 +405,17 @@ private static Locale[] createAvailableLocales() { /* - * Gets the locale string list from LocaleDataMetaInfo class and then + * Gets the locale string list from LocaleDataMetaInfo classes and then * contructs the Locale array and a set of language tags based on the * locale string returned above. */ - String supportedLocaleString = LocaleDataMetaInfo.getSupportedLocaleString("AvailableLocales"); + String supportedLocaleString = createSupportedLocaleString("AvailableLocales"); if (supportedLocaleString.length() == 0) { throw new InternalError("No available locales for JRE"); } - /* - * Look for "|" and construct a new locale string list. - */ - int barIndex = supportedLocaleString.indexOf('|'); - StringTokenizer localeStringTokenizer; - if (isNonENLangSupported()) { - localeStringTokenizer = new StringTokenizer(supportedLocaleString.substring(0, barIndex) - + supportedLocaleString.substring(barIndex + 1)); - } else { - localeStringTokenizer = new StringTokenizer(supportedLocaleString.substring(0, barIndex)); - } + StringTokenizer localeStringTokenizer = new StringTokenizer(supportedLocaleString); int length = localeStringTokenizer.countTokens(); Locale[] locales = new Locale[length + 1]; @@ -430,39 +438,4 @@ } return locales; } - - private static volatile Boolean isNonENSupported = null; - - /* - * Returns true if the non EN resources jar file exists in jre - * extension directory. @returns true if the jar file is there. Otherwise, - * returns false. - */ - private static boolean isNonENLangSupported() { - if (isNonENSupported == null) { - synchronized (JRELocaleProviderAdapter.class) { - if (isNonENSupported == null) { - final String sep = File.separator; - String localeDataJar = - java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.home")) - + sep + "lib" + sep + "ext" + sep + LOCALE_DATA_JAR_NAME; - - /* - * Peek at the installed extension directory to see if - * localedata.jar is installed or not. - */ - final File f = new File(localeDataJar); - isNonENSupported = - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - return f.exists(); - } - }); - } - } - } - return isNonENSupported; - } } --- old/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java 2014-08-22 11:18:41.182109086 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java 2014-08-22 11:18:40.909105052 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,10 @@ */ public class LocaleNameProviderImpl extends LocaleNameProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - public LocaleNameProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public LocaleNameProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -55,12 +54,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags()); } /** @@ -86,8 +85,8 @@ * @see java.util.Locale#getDisplayLanguage(java.util.Locale) */ @Override - public String getDisplayLanguage(String lang, Locale locale) { - return getDisplayString(lang, locale); + public String getDisplayLanguage(String languageCode, Locale locale) { + return getDisplayString(languageCode, locale); } /** @@ -143,8 +142,8 @@ * @see java.util.Locale#getDisplayCountry(java.util.Locale) */ @Override - public String getDisplayCountry(String ctry, Locale locale) { - return getDisplayString(ctry, locale); + public String getDisplayCountry(String countryCode, Locale locale) { + return getDisplayString(countryCode, locale); } /** @@ -164,8 +163,8 @@ * @see java.util.Locale#getDisplayVariant(java.util.Locale) */ @Override - public String getDisplayVariant(String vrnt, Locale locale) { - return getDisplayString("%%"+vrnt, locale); + public String getDisplayVariant(String variant, Locale locale) { + return getDisplayString("%%"+variant, locale); } private String getDisplayString(String key, Locale locale) { @@ -178,6 +177,13 @@ @Override public Set getAvailableLanguageTags() { + return getLangTags(); + } + + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("LocaleNames"); + } return langtags; } } --- old/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java 2014-08-22 11:18:42.721131830 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java 2014-08-22 11:18:42.417127338 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,11 +65,9 @@ private static final int INTEGERSTYLE = 4; private final LocaleProviderAdapter.Type type; - private final Set langtags; - public NumberFormatProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + public NumberFormatProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -86,7 +84,7 @@ @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, DateFormatProviderImpl.getLangTags(type)); } /** @@ -222,6 +220,6 @@ @Override public Set getAvailableLanguageTags() { - return langtags; + return DateFormatProviderImpl.getLangTags(type); } } --- old/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java 2014-08-22 11:18:44.362156082 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java 2014-08-22 11:18:44.067151722 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,11 +40,10 @@ */ public class TimeZoneNameProviderImpl extends TimeZoneNameProvider { private final LocaleProviderAdapter.Type type; - private final Set langtags; + private Set langtags; - TimeZoneNameProviderImpl(LocaleProviderAdapter.Type type, Set langtags) { + TimeZoneNameProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; - this.langtags = langtags; } /** @@ -56,12 +55,12 @@ */ @Override public Locale[] getAvailableLocales() { - return LocaleProviderAdapter.toLocaleArray(langtags); + return LocaleProviderAdapter.toLocaleArray(getLangTags()); } @Override public boolean isSupportedLocale(Locale locale) { - return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags); + return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags()); } /** @@ -78,7 +77,7 @@ * appropriate for daylight saving time even if the specified time zone * has not observed daylight saving time in the past. * - * @param ID a time zone ID string + * @param id a time zone ID string * @param daylight if true, return the daylight saving name. * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or * {@link java.util.TimeZone#SHORT TimeZone.SHORT} @@ -122,6 +121,13 @@ return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getTimeZoneNames(id, n); } + private Set getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("TimeZoneNames"); + } + return langtags; + } + /** * Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for * the given locale. This method is package private. --- old/src/java.base/share/classes/sun/util/resources/LocaleData.java 2014-08-22 11:18:45.926179194 -0700 +++ new/src/java.base/share/classes/sun/util/resources/LocaleData.java 2014-08-22 11:18:45.631174836 -0700 @@ -50,7 +50,6 @@ import java.util.ResourceBundle; import java.util.Set; import sun.util.locale.provider.JRELocaleProviderAdapter; -import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; import static sun.util.locale.provider.LocaleProviderAdapter.Type.CLDR; import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE; --- old/make/gensrc/GensrcLocaleDataMetaInfo.gmk 2014-08-22 11:18:47.538203017 -0700 +++ /dev/null 2014-07-14 16:37:22.333786882 -0700 @@ -1,136 +0,0 @@ -# -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Scan for all locale resources and extract for which locales there exists -# resources. Then put this meta information about existing (supported?) locales -# into LocaleDataMetaInfo.java - -# First go look for all locale files -LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \ - $(JDK_TOPDIR)/src/jdk.localedata/share/classes \ - -name "FormatData_*.java" -o -name "FormatData_*.properties" -o \ - -name "CollationData_*.java" -o -name "CollationData_*.properties" -o \ - -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \ - -name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \ - -name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \ - -name "CalendarData_*.java" -o -name "CalendarData_*.properties" -o \ - -name "BreakIteratorInfo_*.java" -o -name "BreakIteratorRules_*.java") - -# Then translate the locale files into for example: FormatData_sv -LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES))))) - -# Include the list of resources found during the previous compile. --include $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources - -MISSING_RESOURCES := $(filter-out $(LOCALE_RESOURCES), $(PREV_LOCALE_RESOURCES)) -NEW_RESOURCES := $(filter-out $(PREV_LOCALE_RESOURCES), $(LOCALE_RESOURCES)) - -ifneq (, $(MISSING_RESOURCES)$(NEW_RESOURCES)) - # There is a difference in the number of supported resources. Trigger a regeneration. - $(shell $(RM) $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java) -endif - -# The EN locales -EN_LOCALES := en% - -# Locales that don't have any resource files should be included here. -ALL_NON_EN_LOCALES := ja-JP-JP nb-NO nn-NO th-TH-TH - -SED_ARGS := -e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g' - -# This macro creates a sed expression that substitues for example: -# #FormatData_ENLocales# with: en% locales. -define CaptureLocale - $1_LOCALES := $$(subst _,-,$$(filter-out $1, $$(subst $1_,,$$(filter $1_%, $(LOCALE_RESOURCES))))) - $1_EN_LOCALES := $$(filter $(EN_LOCALES), $$($1_LOCALES)) - $1_NON_EN_LOCALES := $$(filter-out $(EN_LOCALES), $$($1_LOCALES)) - - # Special handling for Chinese locales to include implicit scripts - $1_NON_EN_LOCALES := $$(subst zh-CN,zh-CN$$(SPACE)zh-Hans-CN, $$($1_NON_EN_LOCALES)) - $1_NON_EN_LOCALES := $$(subst zh-SG,zh-SG$$(SPACE)zh-Hans-SG, $$($1_NON_EN_LOCALES)) - $1_NON_EN_LOCALES := $$(subst zh-HK,zh-HK$$(SPACE)zh-Hant-HK, $$($1_NON_EN_LOCALES)) - $1_NON_EN_LOCALES := $$(subst zh-MO,zh-MO$$(SPACE)zh-Hant-MO, $$($1_NON_EN_LOCALES)) - $1_NON_EN_LOCALES := $$(subst zh-TW,zh-TW$$(SPACE)zh-Hant-TW, $$($1_NON_EN_LOCALES)) - - ALL_EN_LOCALES += $$($1_EN_LOCALES) - ALL_NON_EN_LOCALES += $$($1_NON_EN_LOCALES) - - # Don't sed in a space if there are no locales. - SED_ARGS += -e 's/$$(HASH)$1_ENLocales$$(HASH)/$$(if $$($1_EN_LOCALES),$$(SPACE)$$($1_EN_LOCALES),)/g' - SED_ARGS += -e 's/$$(HASH)$1_NonENLocales$$(HASH)/$$(if $$($1_NON_EN_LOCALES),$$(SPACE)$$($1_NON_EN_LOCALES),)/g' -endef - -#sun.text.resources.FormatData -$(eval $(call CaptureLocale,FormatData)) - -#sun.text.resources.CollationData -$(eval $(call CaptureLocale,CollationData)) - -#sun.text.resources.BreakIteratorInfo -$(eval $(call CaptureLocale,BreakIteratorInfo)) - -#sun.text.resources.BreakIteratorRules -$(eval $(call CaptureLocale,BreakIteratorRules)) - -#sun.util.resources.TimeZoneNames -$(eval $(call CaptureLocale,TimeZoneNames)) - -#sun.util.resources.LocaleNames -$(eval $(call CaptureLocale,LocaleNames)) - -#sun.util.resources.CurrencyNames -$(eval $(call CaptureLocale,CurrencyNames)) - -#sun.util.resources.CalendarData -$(eval $(call CaptureLocale,CalendarData)) - -SED_ARGS += -e 's/$(HASH)AvailableLocales_ENLocales$(HASH)/$(sort $(ALL_EN_LOCALES))/g' -SED_ARGS += -e 's/$(HASH)AvailableLocales_NonENLocales$(HASH)/$(sort $(ALL_NON_EN_LOCALES))/g' - -$(JDK_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/LocaleDataMetaInfo.java: \ - $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template - $(MKDIR) -p $(@D) - $(ECHO) Creating sun/util/LocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources. - $(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" > $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources - $(SED) $(SED_ARGS) $< > $@ - -GENSRC_LOCALEDATAMETAINFO := $(JDK_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/LocaleDataMetaInfo.java - -################################################################################ - -GENSRC_CRBC_DST := $(JDK_OUTPUTDIR)/gensrc/java.base/sun/util/CoreResourceBundleControl.java -GENSRC_CRBC_CMD := $(JDK_TOPDIR)/make/scripts/localelist.sh - -JRE_NONEXIST_LOCALES := en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh - -$(GENSRC_CRBC_DST): $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/CoreResourceBundleControl-XLocales.java.template \ - $(GENSRC_CRBC_CMD) - $(MKDIR) -p $(@D) - NAWK="$(NAWK)" SED="$(SED)" $(SH) $(GENSRC_CRBC_CMD) "$(JRE_NONEXIST_LOCALES)" $< $@ - -GENSRC_LOCALEDATAMETAINFO += $(GENSRC_CRBC_DST) -GENSRC_JAVA_BASE += $(GENSRC_LOCALEDATAMETAINFO) - -################################################################################ --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/make/gensrc/GensrcCoreResourceBundleControl.gmk 2014-08-22 11:18:47.213198216 -0700 @@ -0,0 +1,38 @@ +# +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +GENSRC_CRBC_DST := $(JDK_OUTPUTDIR)/gensrc/java.base/sun/util/CoreResourceBundleControl.java +GENSRC_CRBC_CMD := $(JDK_TOPDIR)/make/scripts/localelist.sh + +JRE_NONEXIST_LOCALES := en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh + +$(GENSRC_CRBC_DST): $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/CoreResourceBundleControl-XLocales.java.template \ + $(GENSRC_CRBC_CMD) + $(MKDIR) -p $(@D) + NAWK="$(NAWK)" SED="$(SED)" $(SH) $(GENSRC_CRBC_CMD) "$(JRE_NONEXIST_LOCALES)" $< $@ + +GENSRC_JAVA_BASE += $(GENSRC_CRBC_DST) + +################################################################################ --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/JREENLocaleDataMetaInfo.java 2014-08-22 11:18:48.892223028 -0700 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This class contains a map which records the locale list string for + * each resource in sun.util.resources & sun.text.resources. + * It is used to avoid loading non-existent localized resources so that + * jar files won't be opened unnecessary to look up them. + * + * @since 1.6 + */ +package sun.util.locale.provider; + +import java.util.HashMap; + +public class JREENLocaleDataMetaInfo implements LocaleDataMetaInfo { + + private static final HashMap resourceNameToLocales = + new HashMap<>(6); + + + static { + resourceNameToLocales.put("FormatData", + "en en-AU en-CA en-GB en-IE en-IN en-MT en-NZ en-PH en-SG en-US en-ZA"); + resourceNameToLocales.put("TimeZoneNames", "en en-CA en-GB en-IE"); + resourceNameToLocales.put("LocaleNames", "en en-MT en-PH en-SG"); + resourceNameToLocales.put("CurrencyNames", + "en-AU en-CA en-GB en-IE en-IN en-MT en-NZ en-PH en-SG en-US en-ZA"); + resourceNameToLocales.put("CalendarData", "en en-GB en-IE en-MT"); + resourceNameToLocales.put("AvailableLocales", + "en en-AU en-CA en-GB en-IE en-IN en-MT en-NZ en-PH en-SG en-US en-ZA"); + } + + /* + * @param resourceName the resource name + * @return the supported locale string for the passed in resource. + */ + public static String getSupportedLocaleString(String resourceName) { + String supportedLocaleString = resourceNameToLocales.get(resourceName); + return supportedLocaleString != null ? supportedLocaleString : ""; + } + + @Override + public LocaleProviderAdapter.Type getType() { + return LocaleProviderAdapter.Type.JRE; + } + + @Override + public String availableLanguageTags(String category) { + return getSupportedLocaleString(category); + } +} --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java 2014-08-22 11:18:50.517247043 -0700 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.util.locale.provider; + +/** + * LocaleData meta info SPI + * + * @author Naoto Sato + */ +public interface LocaleDataMetaInfo { + + /** + * Returns the type of LocaleProviderAdapter for which this LocaleData + * provides the data. + * @return type The type of the adapter. + */ + public LocaleProviderAdapter.Type getType(); + + /** + * Returns the string concatenation of the supported language tags in + * this LocaleData instance + * @param category category of the locale data. + * @return concatenated language tags, separated by a space. + */ + public String availableLanguageTags(String category); +} --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/src/jdk.localedata/share/classes/sun/util/cldr/sun.util.locale.provider.LocaleDataMetaInfo 2014-08-22 11:18:52.249272639 -0700 @@ -0,0 +1 @@ +sun.util.cldr.CLDRLocaleDataMetaInfo --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/src/jdk.localedata/share/classes/sun/util/locale/provider/JRENonENLocaleDataMetaInfo.java 2014-08-22 11:18:53.972298103 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This class contains a map which records the locale list string for + * each resource in sun.util.resources & sun.text.resources. + * It is used to avoid loading non-existent localized resources so that + * jar files won't be opened unnecessary to look up them. + * + * @since 1.6 + */ +package sun.util.locale.provider; + +import java.util.HashMap; + +public class JRENonENLocaleDataMetaInfo implements LocaleDataMetaInfo { + + private static final HashMap resourceNameToLocales = + new HashMap<>(7); + + + static { + resourceNameToLocales.put("FormatData", + "ar ar-JO ar-LB ar-SY be be-BY bg bg-BG ca ca-ES cs cs-CZ da da-DK de de-AT de-CH de-DE de-LU el el-CY el-GR es es-AR es-BO es-CL es-CO es-CR es-DO es-EC es-ES es-GT es-HN es-MX es-NI es-PA es-PE es-PR es-PY es-SV es-US es-UY es-VE et et-EE fi fi-FI fr fr-BE fr-CA fr-CH fr-FR ga ga-IE hi-IN hr hr-HR hu hu-HU in in-ID is is-IS it it-CH it-IT iw iw-IL ja ja-JP ko ko-KR lt lt-LT lv lv-LV mk mk-MK ms ms-MY mt mt-MT nl nl-BE nl-NL no no-NO no-NO-NY pl pl-PL pt pt-BR pt-PT ro ro-RO ru ru-RU sk sk-SK sl sl-SI sq sq-AL sr sr-BA sr-CS sr-Latn sr-Latn-ME sr-ME sr-RS sv sv-SE th th-TH tr tr-TR uk uk-UA vi vi-VN zh zh-CN zh-Hans-CN zh-HK zh-Hant-HK zh-SG zh-Hans-SG zh-TW zh-Hant-TW"); + resourceNameToLocales.put("CollationData", + "ar be bg ca cs da el es et fi fr hi hr hu is iw ja ko lt lv mk no pl ro ru sk sl sq sr sr-Latn sv th tr uk vi zh zh-HK zh-Hant-HK zh-TW zh-Hant-TW"); + resourceNameToLocales.put("TimeZoneNames", + "de es fr hi it ja ko pt-BR sv zh-CN zh-Hans-CN zh-HK zh-Hant-HK zh-TW zh-Hant-TW"); + resourceNameToLocales.put("LocaleNames", + "ar be bg ca cs da de el el-CY es es-US et fi fr ga hi hr hu in is it iw ja ko lt lv mk ms mt nl no no-NO-NY pl pt pt-BR pt-PT ro ru sk sl sq sr sr-Latn sv th tr uk vi zh zh-HK zh-Hant-HK zh-SG zh-Hans-SG zh-TW zh-Hant-TW"); + resourceNameToLocales.put("CurrencyNames", + "ar-AE ar-BH ar-DZ ar-EG ar-IQ ar-JO ar-KW ar-LB ar-LY ar-MA ar-OM ar-QA ar-SA ar-SD ar-SY ar-TN ar-YE be-BY bg-BG ca-ES cs-CZ da-DK de de-AT de-CH de-DE de-GR de-LU el-CY el-GR es es-AR es-BO es-CL es-CO es-CR es-CU es-DO es-EC es-ES es-GT es-HN es-MX es-NI es-PA es-PE es-PR es-PY es-SV es-US es-UY es-VE et-EE fi-FI fr fr-BE fr-CA fr-CH fr-FR fr-LU ga-IE hi-IN hr-HR hu-HU in-ID is-IS it it-CH it-IT iw-IL ja ja-JP ko ko-KR lt-LT lv-LV mk-MK ms-MY mt-MT nl-BE nl-NL no-NO pl-PL pt pt-BR pt-PT ro-RO ru-RU sk-SK sl-SI sq-AL sr-BA sr-CS sr-Latn-BA sr-Latn-ME sr-Latn-RS sr-ME sr-RS sv sv-SE th-TH tr-TR uk-UA vi-VN zh-CN zh-Hans-CN zh-HK zh-Hant-HK zh-SG zh-Hans-SG zh-TW zh-Hant-TW"); + resourceNameToLocales.put("CalendarData", + "ar be bg ca cs da de el el-CY es es-ES es-US et fi fr fr-CA hi hr hu in-ID is it iw ja ko lt lv mk ms-MY mt mt-MT nl no pl pt pt-BR pt-PT ro ru sk sl sq sr sr-Latn-BA sr-Latn-ME sr-Latn-RS sv th tr uk vi zh"); + resourceNameToLocales.put("AvailableLocales", + "ar ar-AE ar-BH ar-DZ ar-EG ar-IQ ar-JO ar-KW ar-LB ar-LY ar-MA ar-OM ar-QA ar-SA ar-SD ar-SY ar-TN ar-YE be be-BY bg bg-BG ca ca-ES cs cs-CZ da da-DK de de-AT de-CH de-DE de-GR de-LU el el-CY el-GR es es-AR es-BO es-CL es-CO es-CR es-CU es-DO es-EC es-ES es-GT es-HN es-MX es-NI es-PA es-PE es-PR es-PY es-SV es-US es-UY es-VE et et-EE fi fi-FI fr fr-BE fr-CA fr-CH fr-FR fr-LU ga ga-IE hi hi-IN hr hr-HR hu hu-HU in in-ID is is-IS it it-CH it-IT iw iw-IL ja ja-JP ja-JP-JP ko ko-KR lt lt-LT lv lv-LV mk mk-MK ms ms-MY mt mt-MT nb-NO nl nl-BE nl-NL nn-NO no no-NO no-NO-NY pl pl-PL pt pt-BR pt-PT ro ro-RO ru ru-RU sk sk-SK sl sl-SI sq sq-AL sr sr-BA sr-CS sr-Latn sr-Latn-BA sr-Latn-ME sr-Latn-RS sr-ME sr-RS sv sv-SE th th-TH th-TH-TH tr tr-TR uk uk-UA vi vi-VN zh zh-CN zh-HK zh-Hans-CN zh-Hans-SG zh-Hant-HK zh-Hant-TW zh-SG zh-TW"); + } + + /* + * @param resourceName the resource name + * @return the supported locale string for the passed in resource. + */ + public static String getSupportedLocaleString(String resourceName) { + return resourceNameToLocales.get(resourceName); + } + + @Override + public LocaleProviderAdapter.Type getType() { + return LocaleProviderAdapter.Type.JRE; + } + + @Override + public String availableLanguageTags(String category) { + return getSupportedLocaleString(category); + } +} --- /dev/null 2014-07-14 16:37:22.333786882 -0700 +++ new/src/jdk.localedata/share/classes/sun/util/locale/provider/META-INF/services/sun.util.locale.provider.LocaleDataMetaInfo 2014-08-22 11:18:55.687323448 -0700 @@ -0,0 +1 @@ +sun.util.locale.provider.JRENonENLocaleDataMetaInfo --- old/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template 2014-08-22 11:18:57.533350731 -0700 +++ /dev/null 2014-07-14 16:37:22.333786882 -0700 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#warn This file is preprocessed before being compiled - -/* - * This class contains a map which records the locale list string for - * each resource in sun.util.resources & sun.text.resources. - * It is used to avoid loading non-existent localized resources so that - * jar files won't be opened unnecessary to look up them. - * - * @since 1.6 - */ -package sun.util.locale.provider; - -import java.util.HashMap; - - -public class LocaleDataMetaInfo { - - private static final HashMap resourceNameToLocales = - new HashMap(7); - - - static { - /* During JDK build time, #XXX_YYY# will be replaced by a string contain all the locales - supported by the resource. - - Don't remove the space character between " and #. That is put there purposely so that - look up locale string such as "en" could be based on if it contains " en ". - */ - resourceNameToLocales.put("FormatData", - " #FormatData_ENLocales# | #FormatData_NonENLocales# "); - - resourceNameToLocales.put("CollationData", - " #CollationData_ENLocales# | #CollationData_NonENLocales# "); - - resourceNameToLocales.put("BreakIteratorInfo", - " #BreakIteratorInfo_ENLocales# | #BreakIteratorInfo_NonENLocales# "); - - resourceNameToLocales.put("BreakIteratorRules", - " #BreakIteratorRules_ENLocales# | #BreakIteratorRules_NonENLocales# "); - - resourceNameToLocales.put("TimeZoneNames", - " #TimeZoneNames_ENLocales# | #TimeZoneNames_NonENLocales# "); - - resourceNameToLocales.put("LocaleNames", - " #LocaleNames_ENLocales# | #LocaleNames_NonENLocales# "); - - resourceNameToLocales.put("CurrencyNames", - " #CurrencyNames_ENLocales# | #CurrencyNames_NonENLocales# "); - - resourceNameToLocales.put("CalendarData", - " #CalendarData_ENLocales# | #CalendarData_NonENLocales# "); - - resourceNameToLocales.put("AvailableLocales", - " #AvailableLocales_ENLocales# | #AvailableLocales_NonENLocales# "); - } - - /* - * @param resourceName the resource name - * @return the supported locale string for the passed in resource. - */ - public static String getSupportedLocaleString(String resourceName) { - return resourceNameToLocales.get(resourceName); - } -}