提交 e8364968 编写于 作者: N naoto

7199750: Loading sequence of service provider is changed

Reviewed-by: okutsu
上级 60ba0fdd
...@@ -112,7 +112,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -112,7 +112,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
interface Delegate<P extends LocaleServiceProvider> { interface Delegate<P extends LocaleServiceProvider> {
public void addImpl(P impl); public void addImpl(P impl);
public P getImpl(Locale locale); public P getImpl(Locale locale);
} }
/* /*
* Obtain the real SPI implementation, using locale fallback * Obtain the real SPI implementation, using locale fallback
...@@ -137,7 +137,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -137,7 +137,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(BreakIteratorProvider impl) { public void addImpl(BreakIteratorProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -192,7 +192,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -192,7 +192,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(CollatorProvider impl) { public void addImpl(CollatorProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -226,7 +226,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -226,7 +226,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(DateFormatProvider impl) { public void addImpl(DateFormatProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -274,7 +274,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -274,7 +274,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(DateFormatSymbolsProvider impl) { public void addImpl(DateFormatSymbolsProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -308,7 +308,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -308,7 +308,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(DecimalFormatSymbolsProvider impl) { public void addImpl(DecimalFormatSymbolsProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -342,7 +342,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -342,7 +342,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(NumberFormatProvider impl) { public void addImpl(NumberFormatProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -397,7 +397,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -397,7 +397,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(CalendarDataProvider impl) { public void addImpl(CalendarDataProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -438,7 +438,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -438,7 +438,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(CalendarNameProvider impl) { public void addImpl(CalendarNameProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -483,7 +483,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -483,7 +483,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(CurrencyNameProvider impl) { public void addImpl(CurrencyNameProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -524,7 +524,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -524,7 +524,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(LocaleNameProvider impl) { public void addImpl(LocaleNameProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
...@@ -579,7 +579,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { ...@@ -579,7 +579,7 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
@Override @Override
public void addImpl(TimeZoneNameProvider impl) { public void addImpl(TimeZoneNameProvider impl) {
for (Locale l : impl.getAvailableLocales()) { for (Locale l : impl.getAvailableLocales()) {
map.put(l, impl); map.putIfAbsent(l, impl);
} }
} }
......
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
#!/bin/sh #!/bin/sh
# #
# @test # @test
# @bug 4052440 8000997 # @bug 4052440 7199750 8000997
# @summary CurrencyNameProvider tests # @summary CurrencyNameProvider tests
# @run shell ExecTest.sh bar CurrencyNameProviderTest true # @run shell ExecTest.sh bar CurrencyNameProviderTest true
...@@ -32,7 +32,8 @@ import java.util.spi.*; ...@@ -32,7 +32,8 @@ import java.util.spi.*;
import com.foobar.Utils; import com.foobar.Utils;
public class CurrencyNameProviderImpl2 extends CurrencyNameProvider { 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() { public Locale[] getAvailableLocales() {
return avail; return avail;
} }
...@@ -43,8 +44,12 @@ public class CurrencyNameProviderImpl2 extends CurrencyNameProvider { ...@@ -43,8 +44,12 @@ public class CurrencyNameProviderImpl2 extends CurrencyNameProvider {
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
} }
if (c.equals("JPY") && Utils.supportsLocale(avail[0], locale)) { if (c.equals("JPY")) {
if (Utils.supportsLocale(avail[0], locale)) {
return "JPY-tokyo"; return "JPY-tokyo";
} else if (Utils.supportsLocale(avail[1], locale)) {
return "JPY-osaka";
}
} }
return null; return null;
} }
...@@ -55,8 +60,12 @@ public class CurrencyNameProviderImpl2 extends CurrencyNameProvider { ...@@ -55,8 +60,12 @@ public class CurrencyNameProviderImpl2 extends CurrencyNameProvider {
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
} }
if (c.equals("JPY") && Utils.supportsLocale(avail[0], locale)) { if (c.equals("JPY")) {
if (Utils.supportsLocale(avail[0], locale)) {
return "JPY-tokyo"; return "JPY-tokyo";
} else if (Utils.supportsLocale(avail[1], locale)) {
return "JPY-osaka";
}
} }
return null; return null;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册