changeset 19227:f33c7563e888

Clean-up of --force-open-all-module-packages
author alanb
date Tue, 07 Mar 2017 12:37:43 +0000
parents 4c6f2b7d6c9d
children c3257e8a44df c6fd92075dc9
files src/java.base/share/classes/java/lang/reflect/AccessibleObject.java src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java src/java.base/share/classes/sun/launcher/resources/launcher.properties
diffstat 3 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Mon Mar 06 18:44:16 2017 +0000
+++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Tue Mar 07 12:37:43 2017 +0000
@@ -289,24 +289,17 @@
         if (callerModule == Object.class.getModule()) return true;
         if (!declaringModule.isNamed()) return true;
 
-        // package is open to caller
         String pn = packageName(declaringClass);
-        if (declaringModule.isOpen(pn, callerModule)) {
-            printStackIfOpenByBackdoor(declaringModule, pn, caller);
-            return true;
-        }
-
-        // package is exported to caller
-        boolean isExported = declaringModule.isExported(pn, callerModule);
-        boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers());
         int modifiers;
         if (this instanceof Executable) {
             modifiers = ((Executable) this).getModifiers();
         } else {
             modifiers = ((Field) this).getModifiers();
         }
-        if (isExported && isClassPublic) {
 
+        // class is public and package is exported to caller
+        boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers());
+        if (isClassPublic && declaringModule.isExported(pn, callerModule)) {
             // member is public
             if (Modifier.isPublic(modifiers)) {
                 printStackIfExportedByBackdoor(declaringModule, pn, caller);
@@ -322,6 +315,12 @@
             }
         }
 
+        // package is open to caller
+        if (declaringModule.isOpen(pn, callerModule)) {
+            printStackIfOpenByBackdoor(declaringModule, pn, caller);
+            return true;
+        }
+
         if (throwExceptionIfDenied) {
             // not accessible
             String msg = "Unable to make ";
--- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Mon Mar 06 18:44:16 2017 +0000
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Tue Mar 07 12:37:43 2017 +0000
@@ -534,7 +534,6 @@
 
         // ---force-open-all-module-packages
         if (getAndRemoveProperty("jdk.module.forceOpenAllModulePackages") != null) {
-            warn("Opened all packages for deep reflection");
             bootLayer.modules().stream().forEach(m -> {
                 m.getDescriptor()
                  .packages()
--- a/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Mon Mar 06 18:44:16 2017 +0000
+++ b/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Tue Mar 07 12:37:43 2017 +0000
@@ -157,6 +157,9 @@
 \    --add-opens <module>/<package>=<target-module>(,<target-module>)*\n\
 \                      updates <module> to open <package> to\n\
 \                      <target-module>, regardless of module declaration.\n\
+\    --force-open-all-module-packages\n\
+\                      force all modules to open all packages, regardless of\n\
+\                      module declarations.\n\
 \    --disable-@files  disable further argument file expansion\n\
 \    --patch-module <module>=<file>({0}<file>)*\n\
 \                      Override or augment a module with classes and resources\n\