changeset 14298:1ac78e4a10d5

8139067: Re-examine if a consumer module should load bundles from unnamed module Reviewed-by: alanb, mchung, naoto
author okutsu
date Thu, 29 Oct 2015 19:55:39 -0700
parents 1b632228f7e5
children f0ce7f2beb6e
files src/java.base/share/classes/sun/util/locale/provider/ResourceBundleProviderSupport.java test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh test/java/util/ResourceBundle/modules/basic/basic.sh test/java/util/ResourceBundle/modules/modlocal/modlocal.sh test/java/util/ResourceBundle/modules/simple/simple.sh
diffstat 5 files changed, 28 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/util/locale/provider/ResourceBundleProviderSupport.java	Tue Oct 27 20:12:15 2015 -0700
+++ b/src/java.base/share/classes/sun/util/locale/provider/ResourceBundleProviderSupport.java	Thu Oct 29 19:55:39 2015 -0700
@@ -109,15 +109,7 @@
 
         PrivilegedAction<InputStream> pa = () -> {
             try {
-                InputStream in = module.getResourceAsStream(resourceName);
-                if (in == null) {
-                    // for migration, find .properties bundle from unnamed module
-                    Module unnamed = module.getClassLoader() != null
-                            ? module.getClassLoader().getUnnamedModule()
-                            : BootLoader.getUnnamedModule();
-                    return unnamed.getResourceAsStream(resourceName);
-                }
-                return in;
+                return module.getResourceAsStream(resourceName);
             } catch (IOException e) {
                 throw new UncheckedIOException(e);
             }
--- a/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh	Tue Oct 27 20:12:15 2015 -0700
+++ b/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh	Thu Oct 29 19:55:39 2015 -0700
@@ -22,7 +22,10 @@
 #
 
 # @test
-# @summary Basic test for ResourceBundle with modules
+# @bug 8044767
+# @summary Basic test for ResourceBundle with modules; named module "test"
+#          contains resource bundles for root and en, and separate named modules
+#          "eubundles" and "asiabundles" contain other resource bundles.
 
 set -e
 
--- a/test/java/util/ResourceBundle/modules/basic/basic.sh	Tue Oct 27 20:12:15 2015 -0700
+++ b/test/java/util/ResourceBundle/modules/basic/basic.sh	Thu Oct 29 19:55:39 2015 -0700
@@ -22,6 +22,7 @@
 #
 
 # @test
+# @bug 8044767 8139067
 # @summary Basic test case for ResourceBundle with modules;
 #          ResourceBundle.getBundle caller is in module named "test",
 #          resource bundles are grouped in main (module "mainbundles"),
@@ -76,12 +77,13 @@
 $JAVAC -d classes $TESTSRC/src/extra/jdk/test/resources/eu/*.java
 $JAR -cf extra.jar -C classes jdk/test/resources/eu \
                    -C $TESTSRC/src/extra jdk/test/resources/asia
-$JAR -tvf extra.jar
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp &&
-    # properties files on the class path should be picked up.
-    $JAVA -cp extra.jar -mp mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de vi &&
-    # classes on the class path shouldn't.
-    ! $JAVA -cp extra.jar -mp mods -m test/jdk.test.Main es
+STATUS=0
 
-exit $?
+echo "jdk.test.Main should load bundles using ResourceBundleProviders."
+$JAVA -mp mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1
+
+echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path."
+$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main es vi && STATUS=1
+
+exit $STATUS
--- a/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh	Tue Oct 27 20:12:15 2015 -0700
+++ b/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh	Thu Oct 29 19:55:39 2015 -0700
@@ -22,6 +22,7 @@
 #
 
 # @test
+# @bug 8044767 8139067
 # @summary Test case for having resource bundles in a local named module
 #          with no ResourceBundleProviders.
 
@@ -64,10 +65,13 @@
 rm -f extra.jar
 mkdir -p classes
 $JAR -cf extra.jar -C $TESTSRC/src/extra jdk/test/resources
-$JAR -tvf extra.jar
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de &&
-   # properties files on the class path should be picked up.
-   $JAVA -cp extra.jar -mp mods -m test/jdk.test.Main de fr ja zh-tw en vi
+STATUS=0
 
-exit $?
+echo 'jdk.test.Main should load bundles local to named module "test".'
+$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1
+
+echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path."
+$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main vi && STATUS=1
+
+exit $STATUS
--- a/test/java/util/ResourceBundle/modules/simple/simple.sh	Tue Oct 27 20:12:15 2015 -0700
+++ b/test/java/util/ResourceBundle/modules/simple/simple.sh	Thu Oct 29 19:55:39 2015 -0700
@@ -22,9 +22,11 @@
 #
 
 # @test
-# @summary Simple test case for ResourceBundle with modules;
-#          ResourceBundle.getBundle caller is in module named "test" and
-#          all resource bundles are in single module named "bundles".
+# @bug 8044767
+# @summary Simple test case for ResourceBundle with named modules;
+#          ResourceBundle.getBundle caller is in named module "test" and
+#          all resource bundles are in single named module "bundles" with
+#          service providers.
 
 
 set -e