8062006: Add a new locale data name "COMPAT" for java.locale.providers system property to reduce ambiguity
Reviewed-by: okutsu
--- a/jdk/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java Mon Nov 02 14:57:04 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java Mon Nov 02 08:46:19 2015 -0800
@@ -123,25 +123,27 @@
* <ul>
* <li> "CLDR": A provider based on Unicode Consortium's
* <a href="http://cldr.unicode.org/">CLDR Project</a>.
- * <li> "JRE": represents the locale sensitive services that is compatible
- * with the prior JDK releases (same with JDK8's "JRE").
+ * <li> "COMPAT": represents the locale sensitive services that is compatible
+ * with the prior JDK releases up to JDK8 (same as JDK8's "JRE").
* <li> "SPI": represents the locale sensitive services implementing the subclasses of
* this {@code LocaleServiceProvider} class.
* <li> "HOST": A provider that reflects the user's custom settings in the
* underlying operating system. This provider may not be available, depending
* on the Java Runtime Environment implementation.
+ * <li> "JRE": represents a synonym to "COMPAT". This name
+ * is deprecated and will be removed in the future release of JDK.
* </ul>
* <p>
* For example, if the following is specified in the property:
* <pre>
- * java.locale.providers=SPI,CLDR,JRE
+ * java.locale.providers=SPI,CLDR,COMPAT
* </pre>
* the locale sensitive services in the SPI providers are looked up first. If the
* desired locale sensitive service is not available, then the runtime looks for CLDR,
- * JRE in that order.
+ * COMPAT in that order.
* <p>
- * The default order for looking up the preferred locale providers is "CLDR,JRE",
- * so specifying "CLDR,JRE" is identical to the default behavior. Applications which
+ * The default order for looking up the preferred locale providers is "CLDR,COMPAT",
+ * so specifying "CLDR,COMPAT" is identical to the default behavior. Applications which
* require implementations of the locale sensitive services must explicitly specify
* "SPI" in order for the Java runtime to load them from the classpath.
*
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Mon Nov 02 14:57:04 2015 +0100
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Mon Nov 02 08:46:19 2015 -0800
@@ -124,6 +124,10 @@
if (order != null && order.length() != 0) {
String[] types = order.split(",");
for (String type : types) {
+ type = type.trim().toUpperCase(Locale.ROOT);
+ if (type.equals("COMPAT")) {
+ type = "JRE";
+ }
try {
Type aType = Type.valueOf(type.trim().toUpperCase(Locale.ROOT));
if (!typeList.contains(aType)) {
--- a/jdk/test/java/util/Locale/LocaleProviders.sh Mon Nov 02 14:57:04 2015 +0100
+++ b/jdk/test/java/util/Locale/LocaleProviders.sh Mon Nov 02 08:46:19 2015 -0800
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2015, 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
@@ -24,7 +24,7 @@
#
# @test
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577
-# 8010666 8013086 8013233 8013903 8015960 8028771
+# 8010666 8013086 8013233 8013903 8015960 8028771 8062006
# @summary tests for "java.locale.providers" system property
# @compile -XDignore.symbol.file LocaleProviders.java
# @run shell/timeout=600 LocaleProviders.sh
@@ -182,7 +182,7 @@
if [ "${DEFLANG}" != "en" ] && [ "${DEFFMTLANG}" != "en" ]; then
PARAM2=en
PARAM3=US
-elif [ "${DEFLANG}" != "ja" ] && [ "${DEFFMTLANG}" != "ja" ]; then
+elif [ "${DEFLANG}" != "ja" ] && [ "${DEFFMTLANG}" != "ja" ]; then
PARAM2=ja
PARAM3=JP
else
@@ -200,6 +200,8 @@
PARAM3=US
SPICLASSES=
runTest
+PREFLIST=SPI,COMPAT
+runTest
# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
METHODNAME=adapterTest
@@ -209,6 +211,8 @@
PARAM3=GB
SPICLASSES=
runTest
+PREFLIST=CLDR,COMPAT
+runTest
# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
METHODNAME=adapterTest
@@ -218,6 +222,8 @@
PARAM3=GB
SPICLASSES=
runTest
+PREFLIST=COMPAT,CLDR
+runTest
# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
METHODNAME=adapterTest
@@ -227,6 +233,8 @@
PARAM3=
SPICLASSES=
runTest
+PREFLIST=COMPAT,CLDR
+runTest
# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
METHODNAME=adapterTest
@@ -275,6 +283,8 @@
PARAM3=
SPICLASSES=${SPIDIR}
runTest
+PREFLIST=COMPAT
+runTest
# testing 8000615 fix.
METHODNAME=tzNameTest
@@ -284,6 +294,8 @@
PARAM3=
SPICLASSES=${SPIDIR}
runTest
+PREFLIST=COMPAT
+runTest
# testing 8001440 fix.
METHODNAME=bug8001440Test
@@ -314,6 +326,8 @@
PARAM3=
SPICLASSES=${SPIDIR}
runTest
+PREFLIST=COMPAT,SPI
+runTest
# testing 8013903 fix. (Windows only)
METHODNAME=bug8013903Test
@@ -323,12 +337,9 @@
PARAM3=
SPICLASSES=
runTest
-METHODNAME=bug8013903Test
PREFLIST=HOST
-PARAM1=
-PARAM2=
-PARAM3=
-SPICLASSES=
+runTest
+PREFLIST=HOST,COMPAT
runTest
# testing 8027289 fix, if the platform format default is zh_CN
@@ -342,12 +353,10 @@
PARAM3=
SPICLASSES=
runTest
- METHODNAME=bug8027289Test
+ PREFLIST=COMPAT,HOST
+ runTest
PREFLIST=HOST
PARAM1=00A5
- PARAM2=
- PARAM3=
- SPICLASSES=
runTest
fi