diff --git a/jdk/make/java/java/FILES_java.gmk b/jdk/make/java/java/FILES_java.gmk
index f6affbf987b..28894f24abe 100644
--- a/jdk/make/java/java/FILES_java.gmk
+++ b/jdk/make/java/java/FILES_java.gmk
@@ -227,6 +227,7 @@ JAVA_JAVA_java = \
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 \
diff --git a/jdk/src/share/classes/java/text/DateFormatSymbols.java b/jdk/src/share/classes/java/text/DateFormatSymbols.java
index bde39a66ed1..b4c380d2c05 100644
--- a/jdk/src/share/classes/java/text/DateFormatSymbols.java
+++ b/jdk/src/share/classes/java/text/DateFormatSymbols.java
@@ -52,6 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
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 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// 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
diff --git a/jdk/src/share/classes/java/text/DecimalFormat.java b/jdk/src/share/classes/java/text/DecimalFormat.java
index 6d19bedcbf6..38c930372c1 100644
--- a/jdk/src/share/classes/java/text/DecimalFormat.java
+++ b/jdk/src/share/classes/java/text/DecimalFormat.java
@@ -54,6 +54,7 @@ import java.util.concurrent.ConcurrentMap;
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 @@ public class DecimalFormat extends NumberFormat {
* @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 @@ public class DecimalFormat extends NumberFormat {
// 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);
}
diff --git a/jdk/src/share/classes/java/text/DecimalFormatSymbols.java b/jdk/src/share/classes/java/text/DecimalFormatSymbols.java
index 81ab956a437..9274208fe8f 100644
--- a/jdk/src/share/classes/java/text/DecimalFormatSymbols.java
+++ b/jdk/src/share/classes/java/text/DecimalFormatSymbols.java
@@ -52,6 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
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 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
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 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
currencySymbol = currency.getSymbol(locale);
data[1] = intlCurrencySymbol;
data[2] = currencySymbol;
- needCacheUpdate = true;
}
} else {
// default values
@@ -633,10 +598,6 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
// 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 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* @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);
}
diff --git a/jdk/src/share/classes/java/text/NumberFormat.java b/jdk/src/share/classes/java/text/NumberFormat.java
index e155b81b60c..eaed665e54c 100644
--- a/jdk/src/share/classes/java/text/NumberFormat.java
+++ b/jdk/src/share/classes/java/text/NumberFormat.java
@@ -56,7 +56,6 @@ import java.util.concurrent.atomic.AtomicLong;
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
diff --git a/jdk/src/share/classes/java/util/Locale.java b/jdk/src/share/classes/java/util/Locale.java
index 9d469e4660c..198148206d1 100644
--- a/jdk/src/share/classes/java/util/Locale.java
+++ b/jdk/src/share/classes/java/util/Locale.java
@@ -50,7 +50,6 @@ import java.text.MessageFormat;
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.LocaleSyntaxException;
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 @@ public final class Locale implements Cloneable, Serializable {
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 @@ public final class Locale implements Cloneable, Serializable {
* @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 @@ public final class Locale implements Cloneable, Serializable {
* @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()];
diff --git a/jdk/src/share/classes/java/util/TimeZone.java b/jdk/src/share/classes/java/util/TimeZone.java
index 9d9fbcc8fd1..d79e201ce7a 100644
--- a/jdk/src/share/classes/java/util/TimeZone.java
+++ b/jdk/src/share/classes/java/util/TimeZone.java
@@ -430,32 +430,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
private static String[] getDisplayNames(String id, Locale locale) {
- Map>> displayNames = DisplayNames.CACHE;
-
- SoftReference