8062588: Support java.util.spi.*, java.text.spi.*, java.awt.im.spi loaded from classpath

Reviewed-by: alanb
This commit is contained in:
Naoto Sato 2014-12-16 12:48:31 -08:00
parent e9e0b591dc
commit 9cb99ee080
22 changed files with 65 additions and 89 deletions

View File

@ -43,9 +43,8 @@ import java.util.Locale;
* supported by the Java runtime environment itself.
*
* <h3>Packaging of Locale Sensitive Service Provider Implementations</h3>
* Implementations of these locale sensitive services are packaged using the
* <a href="../../../../technotes/guides/extensions/index.html">Java Extension Mechanism</a>
* as installed extensions. A provider identifies itself with a
* Implementations of these locale sensitive services can be made available
* by adding them to the application's class path. A provider identifies itself with a
* provider-configuration file in the resource directory META-INF/services,
* using the fully qualified provider interface class name as the file name.
* The file should contain a list of fully-qualified concrete provider class names,

View File

@ -77,7 +77,8 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter {
public P run() {
P delegate = null;
for (LocaleServiceProvider provider : ServiceLoader.loadInstalled(c)) {
for (LocaleServiceProvider provider :
ServiceLoader.load(c, ClassLoader.getSystemClassLoader())) {
if (delegate == null) {
try {
delegate =

View File

@ -55,9 +55,8 @@ recognition.</P>
<H4><A NAME="Packaging"></A>Packaging Input Methods</H4>
<P>Input methods are packaged as installed extensions, as specified
by the <A HREF="../../../../../technotes/guides/extensions/index.html">Extension
Mechanism</A>. The main JAR file of an input method must contain the
<P>Input methods can be made available by adding them to the application's
class path. The main JAR file of an input method must contain the
file:</P>
<PRE> META-INF/services/java.awt.im.spi.InputMethodDescriptor</PRE>

View File

@ -259,7 +259,8 @@ class ExecutableInputMethodManager extends InputMethodManager
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() {
for (InputMethodDescriptor descriptor :
ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
ServiceLoader.load(InputMethodDescriptor.class,
ClassLoader.getSystemClassLoader())) {
ClassLoader cl = descriptor.getClass().getClassLoader();
javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
}

View File

@ -306,22 +306,6 @@ com/sun/jdi/RedefinePop.sh generic-all
# 8051641
sun/util/calendar/zi/TestZoneInfo310.java generic-all
# 8062588
java/util/Locale/LocaleProviders.sh generic-all
java/util/PluggableLocale/BreakIteratorProviderTest.sh generic-all
java/util/PluggableLocale/CalendarDataProviderTest.sh generic-all
java/util/PluggableLocale/CalendarNameProviderTest.sh generic-all
java/util/PluggableLocale/CollatorProviderTest.sh generic-all
java/util/PluggableLocale/CurrencyNameProviderTest.sh generic-all
java/util/PluggableLocale/DateFormatProviderTest.sh generic-all
java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh generic-all
java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh generic-all
java/util/PluggableLocale/GenericTest.sh generic-all
java/util/PluggableLocale/LocaleNameProviderTest.sh generic-all
java/util/PluggableLocale/NumberFormatProviderTest.sh generic-all
java/util/PluggableLocale/TimeZoneNameProviderTest.sh generic-all
java/util/ResourceBundle/Bug6299235Test.sh generic-all
# 8062512
java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all

View File

@ -137,7 +137,7 @@ echo "DEFFMTCTRY=${DEFFMTCTRY}"
runTest()
{
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES}${PS}${SPICLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
echo ${RUNCMD}
${RUNCMD}
result=$?
@ -189,6 +189,7 @@ else
PARAM2=zh
PARAM3=CN
fi
SPICLASSES=
runTest
# testing SPI is NOT selected, as there is none.
@ -197,6 +198,7 @@ PREFLIST=SPI,JRE
PARAM1=JRE
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
@ -205,6 +207,7 @@ PREFLIST=CLDR,JRE
PARAM1=CLDR
PARAM2=en
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
@ -213,6 +216,7 @@ PREFLIST=JRE,CLDR
PARAM1=JRE
PARAM2=en
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
@ -221,6 +225,7 @@ PREFLIST=JRE,CLDR
PARAM1=CLDR
PARAM2=haw
PARAM3=GB
SPICLASSES=
runTest
# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
@ -229,6 +234,7 @@ PREFLIST=CLDR
PARAM1=CLDR
PARAM2=zh
PARAM3=CN
SPICLASSES=
runTest
# testing FALLBACK provider. SPI and invalid one cases.
@ -237,16 +243,19 @@ PREFLIST=SPI
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
PREFLIST=FOO
PARAM1=JRE
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
PREFLIST=BAR,SPI
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
SPICLASSES=
runTest
# testing 7198834 fix. Only works on Windows Vista or upper.
@ -255,22 +264,25 @@ PREFLIST=HOST
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8000245 fix.
METHODNAME=tzNameTest
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE
PARAM1=Europe/Moscow
PARAM2=
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8000615 fix.
METHODNAME=tzNameTest
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE
PARAM1=America/Los_Angeles
PARAM2=
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8001440 fix.
@ -279,6 +291,7 @@ PREFLIST=CLDR
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8010666 fix.
@ -289,15 +302,17 @@ then
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
fi
# testing 8013086 fix.
METHODNAME=bug8013086Test
PREFLIST="JRE,SPI -Djava.ext.dirs=${SPIDIR}"
PREFLIST=JRE,SPI
PARAM1=ja
PARAM2=JP
PARAM3=
SPICLASSES=${SPIDIR}
runTest
# testing 8013903 fix. (Windows only)
@ -306,12 +321,14 @@ PREFLIST=HOST,JRE
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
METHODNAME=bug8013903Test
PREFLIST=HOST
PARAM1=
PARAM2=
PARAM3=
SPICLASSES=
runTest
# testing 8027289 fix, if the platform format default is zh_CN
@ -323,12 +340,14 @@ if [ "${DEFFMTLANG}" = "zh" ] && [ "${DEFFMTCTRY}" = "CN" ]; then
PARAM1=FFE5
PARAM2=
PARAM3=
SPICLASSES=
runTest
METHODNAME=bug8027289Test
PREFLIST=HOST
PARAM1=00A5
PARAM2=
PARAM3=
SPICLASSES=
runTest
fi

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary BreakIteratorProvider tests
# @run shell ExecTest.sh foo BreakIteratorProviderTest true
# @run shell ExecTest.sh foo BreakIteratorProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 7058207 8000986
# @bug 7058207 8000986 8062588
# @summary CalendarDataProvider tests
# @run shell ExecTest.sh bar CalendarDataProviderTest true
# @run shell ExecTest.sh bar CalendarDataProviderTest

View File

@ -22,6 +22,6 @@
#
# @test
# @bug 8000986
# @bug 8000986 8062588
# @summary CalendarNameProvider tests
# @run shell ExecTest.sh bar CalendarNameProviderTest true
# @run shell ExecTest.sh bar CalendarNameProviderTest

View File

@ -36,13 +36,13 @@ public class ClasspathTest {
ClasspathTest() {
/*
* Since providers can only be loaded from the extension directory,
* this test will fail if they are loaded from classpath.
* Since providers can be loaded from the application's classpath,
* this test will fail if they are NOT loaded from classpath.
*/
Locale OSAKA = new Locale("ja", "JP", "osaka");
List<Locale> availableLocales = Arrays.asList(Locale.getAvailableLocales());
if (availableLocales.contains(OSAKA)) {
throw new RuntimeException("LSS providers were loaded from the class path.");
if (!availableLocales.contains(OSAKA)) {
throw new RuntimeException("LSS providers were NOT loaded from the class path.");
}
}
}

View File

@ -23,7 +23,6 @@
#
#
# @test
# @bug 6388652
# @summary Checks whether providers can only be loaded from extension directories,
# not from classpath.
# @run shell ExecTest.sh bar ClasspathTest false
# @bug 6388652 8062588
# @summary Checks whether providers can be loaded from classpath.
# @run shell ExecTest.sh bar ClasspathTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary CollatorProvider tests
# @run shell ExecTest.sh foo CollatorProviderTest true
# @run shell ExecTest.sh foo CollatorProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7199750 8000997
# @bug 4052440 7199750 8000997 8062588
# @summary CurrencyNameProvider tests
# @run shell ExecTest.sh bar CurrencyNameProviderTest true
# @run shell ExecTest.sh bar CurrencyNameProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7003643
# @bug 4052440 7003643 8062588
# @summary DateFormatProvider tests
# @run shell ExecTest.sh foo DateFormatProviderTest true
# @run shell ExecTest.sh foo DateFormatProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7200341
# @bug 4052440 7200341 8062588
# @summary DateFormatSymbolsProvider tests
# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest true
# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary DecimalFormatSymbolsProvider tests
# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest true
# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest

View File

@ -76,14 +76,6 @@ case "$OS" in
;;
esac
# set classpath and extension directory variables
if [ -d ${TESTJAVA}${FS}lib${FS}ext ]
then
EXTDIRS="${TESTJAVA}${FS}lib${FS}ext${PS}${TESTCLASSES}"
else
EXTDIRS="${TESTJAVA}${FS}jre${FS}lib${FS}ext${PS}${TESTCLASSES}"
fi
case "$1" in
"foo" )
cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
@ -122,12 +114,7 @@ else
fi
# run
if [ "$3" = "true" ]
then
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Djava.ext.dirs=${EXTDIRS} $2 "
else
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
fi
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
echo ${RUNCMD}
${RUNCMD}

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440
# @bug 4052440 8062588
# @summary Generic tests for the pluggable locales feature
# @run shell ExecTest.sh foobar GenericTest true
# @run shell ExecTest.sh foobar GenericTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 8000273
# @bug 4052440 8000273 8062588
# @summary LocaleNameProvider tests
# @run shell ExecTest.sh bar LocaleNameProviderTest true
# @run shell ExecTest.sh bar LocaleNameProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 7003643
# @bug 4052440 7003643 8062588
# @summary NumberFormatProvider tests
# @run shell ExecTest.sh foo NumberFormatProviderTest true
# @run shell ExecTest.sh foo NumberFormatProviderTest

View File

@ -23,6 +23,6 @@
#
#
# @test
# @bug 4052440 8003267
# @bug 4052440 8003267 8062588
# @summary TimeZoneNameProvider tests
# @run shell ExecTest.sh bar TimeZoneNameProviderTest true
# @run shell ExecTest.sh bar TimeZoneNameProviderTest

View File

@ -55,27 +55,14 @@ if [ -z "${TESTJAVA}" ]; then
exit 1
fi
# See if TESTJAVA points to JRE or JDK
if [ -d "${TESTJAVA}${FILESEP}jre" ]; then
JRE_EXT_DIR=${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext
else
JRE_EXT_DIR=${TESTJAVA}${FILESEP}lib${FILESEP}ext
fi
if [ -d "${JRE_EXT_DIR}" ]; then
NEW_EXT_DIR="${JRE_EXT_DIR}${PATHSEP}${TESTSRC}"
else
NEW_EXT_DIR=${TESTSRC}
fi
echo "TESTJAVA=${TESTJAVA}"
echo "TESTSRC=${TESTSRC}"
echo "TESTCLASSES=${TESTCLASSES}"
echo "NEW_EXT_DIR=${NEW_EXT_DIR}"
cd ${TESTSRC}
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} -Djava.ext.dirs=${NEW_EXT_DIR} Bug6299235Test
echo
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}awtres.jar Bug6299235Test
if [ $? -ne 0 ]
then