--- old/make/java/java/FILES_java.gmk Fri Jan 11 10:33:37 2013
+++ new/make/java/java/FILES_java.gmk Fri Jan 11 10:33:35 2013
@@ -227,6 +227,7 @@
sun/util/locale/provider/LocaleResources.java \
sun/util/locale/provider/NumberFormatProviderImpl.java \
sun/util/locale/provider/RuleBasedBreakIterator.java \
+ sun/util/locale/provider/ResourceBundleBasedAdapter.java \
sun/util/locale/provider/SPILocaleProviderAdapter.java \
sun/util/locale/provider/TimeZoneNameProviderImpl.java \
sun/util/locale/provider/TimeZoneNameUtility.java \
--- old/src/share/classes/java/text/DateFormatSymbols.java Fri Jan 11 10:33:43 2013
+++ new/src/share/classes/java/text/DateFormatSymbols.java Fri Jan 11 10:33:41 2013
@@ -52,6 +52,7 @@
import java.util.concurrent.ConcurrentMap;
import sun.util.locale.provider.LocaleProviderAdapter;
import sun.util.locale.provider.LocaleServiceProviderPool;
+import sun.util.locale.provider.ResourceBundleBasedAdapter;
import sun.util.locale.provider.TimeZoneNameUtility;
/**
@@ -680,13 +681,10 @@
// Initialize the fields from the ResourceBundle for locale.
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
// Avoid any potential recursions
- switch (adapter.getAdapterType()) {
- case HOST:
- case SPI:
+ if (!(adapter instanceof ResourceBundleBasedAdapter)) {
adapter = LocaleProviderAdapter.getResourceBundleBased();
- break;
}
- ResourceBundle resource = adapter.getLocaleData().getDateFormatData(locale);
+ ResourceBundle resource = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);
// JRE and CLDR use different keys
// JRE: Eras, short.Eras and narrow.Eras
--- old/src/share/classes/java/text/DecimalFormat.java Fri Jan 11 10:33:48 2013
+++ new/src/share/classes/java/text/DecimalFormat.java Fri Jan 11 10:33:47 2013
@@ -54,6 +54,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import sun.util.locale.provider.LocaleProviderAdapter;
+import sun.util.locale.provider.ResourceBundleBasedAdapter;
/**
* DecimalFormat
is a concrete subclass of
@@ -394,28 +395,17 @@
* @see java.text.NumberFormat#getPercentInstance
*/
public DecimalFormat() {
+ // Get the pattern for the default locale.
Locale def = Locale.getDefault(Locale.Category.FORMAT);
- // try to get the pattern from the cache
- String pattern = cachedLocaleData.get(def);
- if (pattern == null) { /* cache miss */
- // Get the pattern for the default locale.
- LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, def);
- switch (adapter.getAdapterType()) {
- case HOST:
- case SPI:
- adapter = LocaleProviderAdapter.getResourceBundleBased();
- break;
- }
- ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(def);
- String[] all = rb.getStringArray("NumberPatterns");
- pattern = all[0];
- /* update cache */
- cachedLocaleData.putIfAbsent(def, pattern);
+ LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, def);
+ if (!(adapter instanceof ResourceBundleBasedAdapter)) {
+ adapter = LocaleProviderAdapter.getResourceBundleBased();
}
+ String[] all = adapter.getLocaleResources(def).getNumberPatterns();
// Always applyPattern after the symbols are set
this.symbols = DecimalFormatSymbols.getInstance(def);
- applyPattern(pattern, false);
+ applyPattern(all[0], false);
}
@@ -4154,10 +4144,4 @@
// Proclaim JDK 1.1 serial compatibility.
static final long serialVersionUID = 864413376551465018L;
-
- /**
- * Cache to hold the NumberPattern of a Locale.
- */
- private static final ConcurrentMap cachedLocaleData
- = new ConcurrentHashMap<>(3);
}
--- old/src/share/classes/java/text/DecimalFormatSymbols.java Fri Jan 11 10:33:55 2013
+++ new/src/share/classes/java/text/DecimalFormatSymbols.java Fri Jan 11 10:33:53 2013
@@ -52,6 +52,7 @@
import java.util.concurrent.ConcurrentMap;
import sun.util.locale.provider.LocaleProviderAdapter;
import sun.util.locale.provider.LocaleServiceProviderPool;
+import sun.util.locale.provider.ResourceBundleBasedAdapter;
/**
* This class represents the set of symbols (such as the decimal separator,
@@ -542,48 +543,13 @@
private void initialize( Locale locale ) {
this.locale = locale;
- // get resource bundle data - try the cache first
- boolean needCacheUpdate = false;
- Object[] data = cachedLocaleData.get(locale);
- if (data == null) { /* cache miss */
- LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
- // Avoid potential recursions
- switch (adapter.getAdapterType()) {
- case HOST:
- case SPI:
- adapter = LocaleProviderAdapter.getResourceBundleBased();
- break;
- }
- ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(locale);
- data = new Object[3];
-
- // NumberElements look up. First, try the Unicode extension
- String numElemKey;
- String numberType = locale.getUnicodeLocaleType("nu");
- if (numberType != null) {
- numElemKey = numberType + ".NumberElements";
- if (rb.containsKey(numElemKey)) {
- data[0] = rb.getStringArray(numElemKey);
- }
- }
-
- // Next, try DefaultNumberingSystem value
- if (data[0] == null && rb.containsKey("DefaultNumberingSystem")) {
- numElemKey = rb.getString("DefaultNumberingSystem") + ".NumberElements";
- if (rb.containsKey(numElemKey)) {
- data[0] = rb.getStringArray(numElemKey);
- }
- }
-
- // Last resort. No need to check the availability.
- // Just let it throw MissingResourceException when needed.
- if (data[0] == null) {
- data[0] = rb.getStringArray("NumberElements");
- }
-
- needCacheUpdate = true;
+ // get resource bundle data
+ LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
+ // Avoid potential recursions
+ if (!(adapter instanceof ResourceBundleBasedAdapter)) {
+ adapter = LocaleProviderAdapter.getResourceBundleBased();
}
-
+ Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();
String[] numberElements = (String[]) data[0];
decimalSeparator = numberElements[0].charAt(0);
@@ -618,7 +584,6 @@
currencySymbol = currency.getSymbol(locale);
data[1] = intlCurrencySymbol;
data[2] = currencySymbol;
- needCacheUpdate = true;
}
} else {
// default values
@@ -633,10 +598,6 @@
// standard decimal separator for all locales that we support.
// If that changes, add a new entry to NumberElements.
monetarySeparator = decimalSeparator;
-
- if (needCacheUpdate) {
- cachedLocaleData.putIfAbsent(locale, data);
- }
}
/**
@@ -850,11 +811,4 @@
* @since JDK 1.1.6
*/
private int serialVersionOnStream = currentSerialVersion;
-
- /**
- * cache to hold the NumberElements and the Currency
- * of a Locale.
- */
- private static final ConcurrentMap cachedLocaleData
- = new ConcurrentHashMap<>(3);
}
--- old/src/share/classes/java/text/NumberFormat.java Fri Jan 11 10:34:00 2013
+++ new/src/share/classes/java/text/NumberFormat.java Fri Jan 11 10:33:59 2013
@@ -56,7 +56,6 @@
import java.util.spi.LocaleServiceProvider;
import sun.util.locale.provider.LocaleProviderAdapter;
import sun.util.locale.provider.LocaleServiceProviderPool;
-import sun.util.resources.LocaleData;
/**
* NumberFormat
is the abstract base class for all number
--- old/src/share/classes/java/util/Locale.java Fri Jan 11 10:34:06 2013
+++ new/src/share/classes/java/util/Locale.java Fri Jan 11 10:34:05 2013
@@ -50,7 +50,6 @@
import java.util.spi.LocaleNameProvider;
import sun.security.action.GetPropertyAction;
-import sun.util.locale.provider.LocaleServiceProviderPool;
import sun.util.locale.BaseLocale;
import sun.util.locale.InternalLocaleBuilder;
import sun.util.locale.LanguageTag;
@@ -61,7 +60,9 @@
import sun.util.locale.LocaleUtils;
import sun.util.locale.ParseStatus;
import sun.util.locale.provider.LocaleProviderAdapter;
-import sun.util.resources.OpenListResourceBundle;
+import sun.util.locale.provider.LocaleResources;
+import sun.util.locale.provider.LocaleServiceProviderPool;
+import sun.util.locale.provider.ResourceBundleBasedAdapter;
/**
* A Locale
object represents a specific geographical, political,
@@ -1779,20 +1780,15 @@
if (baseLocale.getVariant().length() == 0)
return "";
- OpenListResourceBundle bundle = LocaleProviderAdapter.forJRE().getLocaleData().getLocaleNames(inLocale);
+ LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale);
- String names[] = getDisplayVariantArray(bundle, inLocale);
+ String names[] = getDisplayVariantArray(inLocale);
// Get the localized patterns for formatting a list, and use
// them to format the list.
- String listPattern = null;
- String listCompositionPattern = null;
- try {
- listPattern = bundle.getString("ListPattern");
- listCompositionPattern = bundle.getString("ListCompositionPattern");
- } catch (MissingResourceException e) {
- }
- return formatList(names, listPattern, listCompositionPattern);
+ return formatList(names,
+ lr.getLocaleName("ListPattern"),
+ lr.getLocaleName("ListCompositionPattern"));
}
/**
@@ -1837,23 +1833,17 @@
* @throws NullPointerException if inLocale
is null
*/
public String getDisplayName(Locale inLocale) {
- OpenListResourceBundle bundle = LocaleProviderAdapter.forJRE().getLocaleData().getLocaleNames(inLocale);
+ LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale);
String languageName = getDisplayLanguage(inLocale);
String scriptName = getDisplayScript(inLocale);
String countryName = getDisplayCountry(inLocale);
- String[] variantNames = getDisplayVariantArray(bundle, inLocale);
+ String[] variantNames = getDisplayVariantArray(inLocale);
// Get the localized patterns for formatting a display name.
- String displayNamePattern = null;
- String listPattern = null;
- String listCompositionPattern = null;
- try {
- displayNamePattern = bundle.getString("DisplayNamePattern");
- listPattern = bundle.getString("ListPattern");
- listCompositionPattern = bundle.getString("ListCompositionPattern");
- } catch (MissingResourceException e) {
- }
+ String displayNamePattern = lr.getLocaleName("DisplayNamePattern");
+ String listPattern = lr.getLocaleName("ListPattern");
+ String listCompositionPattern = lr.getLocaleName("ListCompositionPattern");
// The display name consists of a main name, followed by qualifiers.
// Typically, the format is "MainName (Qualifier, Qualifier)" but this
@@ -2005,7 +1995,7 @@
* @param bundle the ResourceBundle to use to get the display names
* @return an array of display names, possible of zero length.
*/
- private String[] getDisplayVariantArray(OpenListResourceBundle bundle, Locale inLocale) {
+ private String[] getDisplayVariantArray(Locale inLocale) {
// Split the variant name into tokens separated by '_'.
StringTokenizer tokenizer = new StringTokenizer(baseLocale.getVariant(), "_");
String[] names = new String[tokenizer.countTokens()];
--- old/src/share/classes/java/util/TimeZone.java Fri Jan 11 10:34:12 2013
+++ new/src/share/classes/java/util/TimeZone.java Fri Jan 11 10:34:11 2013
@@ -430,32 +430,7 @@
}
private static String[] getDisplayNames(String id, Locale locale) {
- Map>> displayNames = DisplayNames.CACHE;
-
- SoftReference