< prev index next >

src/java.base/share/classes/java/lang/Module.java

Print this page

        

@@ -124,11 +124,11 @@
         this.loader = loader;
         this.descriptor = descriptor;
 
         // define module to VM
 
-        boolean isOpen = descriptor.isOpen();
+        boolean isOpen = descriptor.isOpen() || descriptor.isAutomatic();
         Version version = descriptor.version().orElse(null);
         String vs = Objects.toString(version, null);
         String loc = Objects.toString(uri, null);
         String[] packages = descriptor.packages().toArray(new String[0]);
         defineModule0(this, isOpen, vs, loc, packages);

@@ -1040,13 +1040,10 @@
         // update VM first in case it fails. This is a no-op if another thread
         // beats us to add the package first
         if (syncVM) {
             // throws IllegalStateException if defined to another module
             addPackage0(this, pn);
-            if (descriptor.isOpen() || descriptor.isAutomatic()) {
-                addExportsToAll0(this, pn);
-            }
         }
         extraPackages.putIfAbsent(pn, Boolean.TRUE);
     }
 
 

@@ -1205,18 +1202,14 @@
      */
     private static void initExportsAndOpens(Module m,
                                             Map<String, Module> nameToSource,
                                             Map<String, Module> nameToModule,
                                             List<ModuleLayer> parents) {
-        // The VM doesn't special case open or automatic modules so need to
-        // export all packages
+        // The VM special cases open and automatic modules so don't need to
+        // export their packages
         ModuleDescriptor descriptor = m.getDescriptor();
         if (descriptor.isOpen() || descriptor.isAutomatic()) {
-            assert descriptor.opens().isEmpty();
-            for (String source : descriptor.packages()) {
-                addExportsToAll0(m, source);
-            }
             return;
         }
 
         Map<String, Set<Module>> openPackages = new HashMap<>();
         Map<String, Set<Module>> exportedPackages = new HashMap<>();
< prev index next >