7199750: Loading sequence of service provider is changed
authornaoto
Thu, 15 Nov 2012 20:17:05 -0800
changeset 14511 d386ddd45711
parent 14510 01a2a198d9ca
child 14512 4ec51f4254ab
7199750: Loading sequence of service provider is changed Reviewed-by: okutsu
jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java
jdk/test/java/util/PluggableLocale/CurrencyNameProviderTest.sh
jdk/test/java/util/PluggableLocale/barprovider.jar
jdk/test/java/util/PluggableLocale/providersrc/CurrencyNameProviderImpl2.java
--- a/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java	Fri Nov 16 10:34:14 2012 +0800
+++ b/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java	Thu Nov 15 20:17:05 2012 -0800
@@ -91,7 +91,7 @@
                                       IllegalAccessException e) {
                                 LocaleServiceProviderPool.config(SPILocaleProviderAdapter.class, e.toString());
                                 return null;
-                    }
+                            }
                         }
 
                         ((Delegate)delegate).addImpl(provider);
@@ -112,7 +112,7 @@
     interface Delegate<P extends LocaleServiceProvider> {
         public void addImpl(P impl);
         public P getImpl(Locale locale);
-}
+    }
 
     /*
      * Obtain the real SPI implementation, using locale fallback
@@ -137,7 +137,7 @@
         @Override
         public void addImpl(BreakIteratorProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -192,7 +192,7 @@
         @Override
         public void addImpl(CollatorProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -226,7 +226,7 @@
         @Override
         public void addImpl(DateFormatProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -274,7 +274,7 @@
         @Override
         public void addImpl(DateFormatSymbolsProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -308,7 +308,7 @@
         @Override
         public void addImpl(DecimalFormatSymbolsProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -342,7 +342,7 @@
         @Override
         public void addImpl(NumberFormatProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -397,7 +397,7 @@
         @Override
         public void addImpl(CalendarDataProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -438,7 +438,7 @@
         @Override
         public void addImpl(CalendarNameProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -483,7 +483,7 @@
         @Override
         public void addImpl(CurrencyNameProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -524,7 +524,7 @@
         @Override
         public void addImpl(LocaleNameProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
@@ -579,7 +579,7 @@
         @Override
         public void addImpl(TimeZoneNameProvider impl) {
             for (Locale l : impl.getAvailableLocales()) {
-                map.put(l, impl);
+                map.putIfAbsent(l, impl);
             }
         }
 
--- a/jdk/test/java/util/PluggableLocale/CurrencyNameProviderTest.sh	Fri Nov 16 10:34:14 2012 +0800
+++ b/jdk/test/java/util/PluggableLocale/CurrencyNameProviderTest.sh	Thu Nov 15 20:17:05 2012 -0800
@@ -23,6 +23,6 @@
 #!/bin/sh
 #
 # @test
-# @bug 4052440 8000997
+# @bug 4052440 7199750 8000997
 # @summary CurrencyNameProvider tests
 # @run shell ExecTest.sh bar CurrencyNameProviderTest true
Binary file jdk/test/java/util/PluggableLocale/barprovider.jar has changed
--- a/jdk/test/java/util/PluggableLocale/providersrc/CurrencyNameProviderImpl2.java	Fri Nov 16 10:34:14 2012 +0800
+++ b/jdk/test/java/util/PluggableLocale/providersrc/CurrencyNameProviderImpl2.java	Thu Nov 15 20:17:05 2012 -0800
@@ -32,7 +32,8 @@
 import com.foobar.Utils;
 
 public class CurrencyNameProviderImpl2 extends CurrencyNameProvider {
-    static Locale[] avail = {new Locale("ja", "JP", "tokyo")};
+    static Locale[] avail = {new Locale("ja", "JP", "tokyo"),
+                             new Locale("ja", "JP", "osaka"), };
     public Locale[] getAvailableLocales() {
         return avail;
     }
@@ -43,8 +44,12 @@
             throw new IllegalArgumentException("locale is not supported: "+locale);
         }
 
-        if (c.equals("JPY") && Utils.supportsLocale(avail[0], locale)) {
-            return "JPY-tokyo";
+        if (c.equals("JPY")) {
+            if (Utils.supportsLocale(avail[0], locale)) {
+                return "JPY-tokyo";
+            } else if (Utils.supportsLocale(avail[1], locale)) {
+                return "JPY-osaka";
+            }
         }
         return null;
     }
@@ -55,8 +60,12 @@
             throw new IllegalArgumentException("locale is not supported: "+locale);
         }
 
-        if (c.equals("JPY") && Utils.supportsLocale(avail[0], locale)) {
-            return "JPY-tokyo";
+        if (c.equals("JPY")) {
+            if (Utils.supportsLocale(avail[0], locale)) {
+                return "JPY-tokyo";
+            } else if (Utils.supportsLocale(avail[1], locale)) {
+                return "JPY-osaka";
+            }
         }
         return null;
     }