8177530: Module system implementation refresh (4/2017)
authoralanb
Fri, 07 Apr 2017 08:08:26 +0000
changeset 44573 245bb4e6f983
parent 44505 d534f4b43d26
child 44574 0bfc30a4b905
8177530: Module system implementation refresh (4/2017) Reviewed-by: jjg Contributed-by: alan.bateman@oracle.com, jan.lahoda@oracle.com
langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java
langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocletInvoker.java
langtools/test/TEST.ROOT
langtools/test/com/sun/javadoc/testCustomTag/taglets/CustomTag.java
langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java
langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java
langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java
langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
langtools/test/jdk/javadoc/tool/CheckResourceKeys.java
langtools/test/jdk/jshell/KullaTesting.java
langtools/test/tools/javac/6410653/T6410653.java
langtools/test/tools/javac/T6406771.java
langtools/test/tools/javac/diags/CheckExamples.java
langtools/test/tools/javac/diags/CheckResourceKeys.java
langtools/test/tools/javac/diags/examples/NoJavaLang.java
langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java
langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java
langtools/test/tools/javac/modules/AddLimitMods.java
langtools/test/tools/javac/modules/AutomaticModules.java
langtools/test/tools/javac/modules/IncubatingTest.java
langtools/test/tools/javac/treeannotests/TestProcessor.java
langtools/test/tools/javac/warnings/VerifyLintDescriptions.java
langtools/test/tools/javadoc/CheckResourceKeys.java
--- a/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package crules;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -76,7 +74,7 @@
     private void addExports(String moduleName, String... packageNames) {
         for (String packageName : packageNames) {
             try {
-                Layer layer = Layer.boot();
+                ModuleLayer layer = ModuleLayer.boot();
                 Optional<Module> m = layer.findModule(moduleName);
                 if (!m.isPresent())
                     throw new Error("module not found: " + moduleName);
--- a/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Fri Apr 07 08:08:26 2017 +0000
@@ -106,7 +106,7 @@
     static {
         Class<?> c = null;
         try {
-            c = Class.forName("java.lang.reflect.Module");
+            c = Class.forName("java.lang.Module");
         } catch (Throwable t) {
         }
         useLegacy = (c == null);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Apr 07 08:08:26 2017 +0000
@@ -1240,7 +1240,7 @@
                     case ALL_SYSTEM:
                         modules = new HashSet<>(syms.getAllModules())
                                 .stream()
-                                .filter(systemModulePred.and(observablePred).and(noIncubatorPred));
+                                .filter(systemModulePred.and(observablePred));
                         break;
                     case ALL_MODULE_PATH:
                         modules = new HashSet<>(syms.getAllModules())
@@ -1265,6 +1265,15 @@
 
         result.add(syms.unnamedModule);
 
+        boolean hasAutomatic = result.stream().anyMatch(IS_AUTOMATIC);
+
+        if (hasAutomatic) {
+            syms.getAllModules()
+                .stream()
+                .filter(IS_AUTOMATIC)
+                .forEach(result::add);
+        }
+
         String incubatingModules = result.stream()
                 .filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
                 .map(msym -> msym.name.toString())
@@ -1282,6 +1291,9 @@
             rootModules.forEach(m -> m.version = version);
         }
     }
+    //where:
+        private static final Predicate<ModuleSymbol> IS_AUTOMATIC =
+                m -> (m.flags_field & Flags.AUTOMATIC_MODULE) != 0;
 
     public boolean isInModuleGraph(ModuleSymbol msym) {
         return allModules == null || allModules.contains(msym);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Apr 07 08:08:26 2017 +0000
@@ -1282,8 +1282,7 @@
                     }
 
                     // finally clean up the module name
-                    mn =  mn.replaceAll("(\\.|\\d)*$", "")    // remove trailing version
-                            .replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
+                    mn =  mn.replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
                             .replaceAll("(\\.)(\\1)+", ".")   // collapse repeating dots
                             .replaceAll("^\\.", "")           // drop leading dots
                             .replaceAll("\\.$", "");          // drop trailing dots
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Fri Apr 07 08:08:26 2017 +0000
@@ -183,7 +183,7 @@
     }
 
     /**
-     * Wrapper class for java.lang.reflect.Module. To materialize a handle use the static factory
+     * Wrapper class for java.lang.Module. To materialize a handle use the static factory
      * methods Module#getModule(Class<?>) or Module#getUnnamedModule(ClassLoader).
      */
     public static class Module {
@@ -236,9 +236,9 @@
         }
 
         // -----------------------------------------------------------------------------------------
-        // on java.lang.reflect.Module
+        // on java.lang.Module
         private static Method addExportsMethod = null;
-        // on java.lang.reflect.Module
+        // on java.lang.Module
         private static Method addUsesMethod = null;
         // on java.lang.Class
         private static Method getModuleMethod;
@@ -248,7 +248,7 @@
         private static void init() {
             if (addExportsMethod == null) {
                 try {
-                    Class<?> moduleClass = Class.forName("java.lang.reflect.Module", false, null);
+                    Class<?> moduleClass = Class.forName("java.lang.Module", false, null);
                     addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class<?>[] { Class.class });
                     addExportsMethod = moduleClass.getDeclaredMethod("addExports",
                                                         new Class<?>[] { String.class, moduleClass });
@@ -318,7 +318,7 @@
     }
 
     /**
-     * Wrapper class for java.lang.module.Layer.
+     * Wrapper class for java.lang.ModuleLayer.
      */
     public static final class Layer {
         private final Object theRealLayer;
@@ -372,7 +372,7 @@
         private static void init() {
             if (layerClass == null) {
                 try {
-                    layerClass = Class.forName("java.lang.reflect.Layer", false, null);
+                    layerClass = Class.forName("java.lang.ModuleLayer", false, null);
                     bootMethod = layerClass.getDeclaredMethod("boot");
                     defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
                                 Configuration.getConfigurationClass(),
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Fri Apr 07 08:08:26 2017 +0000
@@ -292,7 +292,7 @@
             Method getModuleMethod = Class.class.getDeclaredMethod("getModule");
             Object thisModule = getModuleMethod.invoke(getClass());
 
-            Class<?> moduleClass = Class.forName("java.lang.reflect.Module");
+            Class<?> moduleClass = Class.forName("java.lang.Module");
             Method addExportsMethod = moduleClass.getDeclaredMethod("addExports", String.class, moduleClass);
 
             Method getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule");
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocletInvoker.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocletInvoker.java	Fri Apr 07 08:08:26 2017 +0000
@@ -379,7 +379,7 @@
             Method getModuleMethod = Class.class.getDeclaredMethod("getModule");
             Object thisModule = getModuleMethod.invoke(getClass());
 
-            Class<?> moduleClass = Class.forName("java.lang.reflect.Module");
+            Class<?> moduleClass = Class.forName("java.lang.Module");
             Method addExportsMethod = moduleClass.getDeclaredMethod("addExports", String.class, moduleClass);
 
             Method getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule");
--- a/langtools/test/TEST.ROOT	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/TEST.ROOT	Fri Apr 07 08:08:26 2017 +0000
@@ -14,8 +14,8 @@
 # Group definitions
 groups=TEST.groups
 
-# Tests using jtreg 4.2 b05 features
-requiredVersion=4.2 b05
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/langtools/test/com/sun/javadoc/testCustomTag/taglets/CustomTag.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/com/sun/javadoc/testCustomTag/taglets/CustomTag.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package taglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Fri Apr 07 08:08:26 2017 +0000
@@ -23,8 +23,6 @@
 
 package taglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Fri Apr 07 08:08:26 2017 +0000
@@ -33,8 +33,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -265,7 +263,7 @@
      * Get the set of keys from the javadoc resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_javadoc = Layer.boot().findModule("jdk.javadoc").get();
+        Module jdk_javadoc = ModuleLayer.boot().findModule("jdk.javadoc").get();
         String[] names = {
                 "jdk.javadoc.internal.doclets.formats.html.resources.standard",
                 "jdk.javadoc.internal.doclets.toolkit.resources.doclets",
--- a/langtools/test/jdk/jshell/KullaTesting.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/jdk/jshell/KullaTesting.java	Fri Apr 07 08:08:26 2017 +0000
@@ -30,7 +30,6 @@
 import java.lang.reflect.Method;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.file.Paths;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -211,11 +210,11 @@
 
     public ClassLoader createAndRunFromModule(String moduleName, Path modPath) {
         ModuleFinder finder = ModuleFinder.of(modPath);
-        Layer parent = Layer.boot();
+        ModuleLayer parent = ModuleLayer.boot();
         Configuration cf = parent.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(moduleName));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = parent.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
         ClassLoader loader = layer.findLoader(moduleName);
         ClassLoader ccl = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(loader);
--- a/langtools/test/tools/javac/6410653/T6410653.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/6410653/T6410653.java	Fri Apr 07 08:08:26 2017 +0000
@@ -31,7 +31,6 @@
  */
 
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.io.File;
 import java.io.ByteArrayOutputStream;
 import javax.tools.*;
--- a/langtools/test/tools/javac/T6406771.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/T6406771.java	Fri Apr 07 08:08:26 2017 +0000
@@ -11,9 +11,9 @@
 // Editing the imports and other leading text may affect the golden text in the tests field.
 // Also beware of scripts that auto-expand tabs to spaces.
 
+
+
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.*;
--- a/langtools/test/tools/javac/diags/CheckExamples.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/diags/CheckExamples.java	Fri Apr 07 08:08:26 2017 +0000
@@ -39,8 +39,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.nio.file.*;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.*;
@@ -111,7 +109,7 @@
             }
         }
 
-        Module jdk_compiler = Layer.boot().findModule("jdk.compiler").get();
+        Module jdk_compiler = ModuleLayer.boot().findModule("jdk.compiler").get();
         ResourceBundle b =
             ResourceBundle.getBundle("com.sun.tools.javac.resources.compiler", jdk_compiler);
         Set<String> resourceKeys = new TreeSet<String>(b.keySet());
--- a/langtools/test/tools/javac/diags/CheckResourceKeys.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java	Fri Apr 07 08:08:26 2017 +0000
@@ -31,8 +31,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -395,7 +393,7 @@
      * Get the set of keys from the javac resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_compiler = Layer.boot().findModule("jdk.compiler").get();
+        Module jdk_compiler = ModuleLayer.boot().findModule("jdk.compiler").get();
         Set<String> results = new TreeSet<String>();
         for (String name : new String[]{"javac", "compiler"}) {
             ResourceBundle b =
--- a/langtools/test/tools/javac/diags/examples/NoJavaLang.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoJavaLang.java	Fri Apr 07 08:08:26 2017 +0000
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.fatal.err.no.java.lang
-// options: -source 8 -target 8 -Xbootclasspath:
+// options: -source 8 -target 8 -Xbootclasspath: -classpath .
 // run: backdoor
 
 class NoJavaLang { }
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Fri Apr 07 08:08:26 2017 +0000
@@ -74,7 +74,7 @@
 
     // test with bootclasspath, for as long as its around
     void testBootClassPath() {
-        String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", "." };
+        String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", ".", "-classpath", "." };
         test(bcpOpts, compilerErrorMessage);
     }
 
--- a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java	Fri Apr 07 08:08:26 2017 +0000
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
@@ -102,7 +100,7 @@
     protected void addExports(String moduleName, String... packageNames) {
         for (String packageName : packageNames) {
             try {
-                Layer layer = Layer.boot();
+                ModuleLayer layer = ModuleLayer.boot();
                 Optional<Module> m = layer.findModule(moduleName);
                 if (!m.isPresent())
                     throw new Error("module not found: " + moduleName);
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Fri Apr 07 08:08:26 2017 +0000
@@ -418,13 +418,13 @@
                                       "    public static void main(String... args) throws Exception {\n");
 
                 for (Entry<String, String> e : MODULES_TO_CHECK_TO_SAMPLE_CLASS.entrySet()) {
-                    testClassNamed.append("        System.err.println(\"visible:" + e.getKey() + ":\" + java.lang.reflect.Layer.boot().findModule(\"" + e.getKey() + "\").isPresent());\n");
+                    testClassNamed.append("        System.err.println(\"visible:" + e.getKey() + ":\" + ModuleLayer.boot().findModule(\"" + e.getKey() + "\").isPresent());\n");
                 }
 
                 testClassNamed.append("        Class<?> cp = Class.forName(Test.class.getClassLoader().getUnnamedModule(), \"cp.CP\");\n");
                 testClassNamed.append("        cp.getDeclaredMethod(\"runMe\").invoke(null);\n");
 
-                testClassNamed.append("        Class<?> automatic = Class.forName(java.lang.reflect.Layer.boot().findModule(\"automatic\").get(), \"automatic.Automatic\");\n");
+                testClassNamed.append("        Class<?> automatic = Class.forName(ModuleLayer.boot().findModule(\"automatic\").get(), \"automatic.Automatic\");\n");
                 testClassNamed.append("        automatic.getDeclaredMethod(\"runMe\").invoke(null);\n");
 
                 testClassNamed.append("    }\n" +
--- a/langtools/test/tools/javac/modules/AutomaticModules.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/modules/AutomaticModules.java	Fri Apr 07 08:08:26 2017 +0000
@@ -300,9 +300,8 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        expected = Arrays.asList("Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read: m1x, apiB, automaticB)",
-                                 "Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
-                                 "2 errors");
+        expected = Arrays.asList("Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
+                                 "1 error");
 
         if (!expected.equals(log)) {
             throw new Exception("expected output not found: " + log);
@@ -310,7 +309,7 @@
     }
 
     @Test
-    public void testDropTrailingVersion(Path base) throws Exception {
+    public void testWithTrailingVersion(Path base) throws Exception {
         Path legacySrc = base.resolve("legacy-src");
         tb.writeJavaFiles(legacySrc,
                           "package api; public class Api {}");
@@ -348,7 +347,7 @@
         Files.createDirectories(classes);
 
         tb.writeJavaFiles(m,
-                          "module m { requires test; }",
+                          "module m { requires test1; }",
                           "package impl; public class Impl { public void e(api.Api api) { } }");
 
         new JavacTask(tb)
@@ -358,4 +357,70 @@
                 .run()
                 .writeAll();
     }
+
+    @Test
+    public void testMultipleAutomatic(Path base) throws Exception {
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        for (char c : new char[] {'A', 'B'}) {
+            Path automaticSrc = base.resolve("automaticSrc" + c);
+            tb.writeJavaFiles(automaticSrc, "package api" + c + "; public class Api {}");
+            Path automaticClasses = base.resolve("automaticClasses" + c);
+            tb.createDirectories(automaticClasses);
+
+            String automaticLog = new JavacTask(tb)
+                                    .outdir(automaticClasses)
+                                    .files(findJavaFiles(automaticSrc))
+                                    .run()
+                                    .writeAll()
+                                    .getOutput(Task.OutputKind.DIRECT);
+
+            if (!automaticLog.isEmpty())
+                throw new Exception("expected output not found: " + automaticLog);
+
+            Path automaticJar = modulePath.resolve("automatic" + c + "-1.0.jar");
+
+            new JarTask(tb, automaticJar)
+              .baseDir(automaticClasses)
+              .files("api" + c + "/Api.class")
+              .run();
+        }
+
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src.resolve("m1x"),
+                          "package impl; public class Impl { apiA.Api a; apiB.Api b; }");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("--module-path", modulePath.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList("Impl.java:1:35: compiler.err.package.not.visible: apiA, (compiler.misc.not.def.access.does.not.read.from.unnamed: apiA, automaticA)",
+                                              "Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read.from.unnamed: apiB, automaticB)",
+                                              "2 errors");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        new JavacTask(tb)
+                .options("--module-path", modulePath.toString(),
+                         "--add-modules", "automaticA",
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+    }
 }
--- a/langtools/test/tools/javac/modules/IncubatingTest.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/modules/IncubatingTest.java	Fri Apr 07 08:08:26 2017 +0000
@@ -122,14 +122,11 @@
                          "-XDrawDiagnostics")
                 .outdir(testClasses)
                 .files(findJavaFiles(testSrc))
-                .run(Expect.FAIL)
+                .run(Expect.SUCCESS)
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        expected = Arrays.asList(
-                "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)",
-                "1 error"
-        );
+        expected = Arrays.asList("");
 
         if (!expected.equals(log)) {
             throw new AssertionError("Unexpected output: " + log);
--- a/langtools/test/tools/javac/treeannotests/TestProcessor.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/treeannotests/TestProcessor.java	Fri Apr 07 08:08:26 2017 +0000
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.io.*;
 import java.util.*;
 import javax.annotation.processing.*;
--- a/langtools/test/tools/javac/warnings/VerifyLintDescriptions.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javac/warnings/VerifyLintDescriptions.java	Fri Apr 07 08:08:26 2017 +0000
@@ -30,8 +30,6 @@
  *          jdk.compiler/com.sun.tools.javac.util
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -42,7 +40,7 @@
 
 public class VerifyLintDescriptions {
     public static void main(String... args) {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
         Module jdk_compiler = boot.findModule("jdk.compiler").get();
         ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
                                                     Locale.US,
--- a/langtools/test/tools/javadoc/CheckResourceKeys.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/langtools/test/tools/javadoc/CheckResourceKeys.java	Fri Apr 07 08:08:26 2017 +0000
@@ -32,8 +32,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -229,7 +227,7 @@
      * Get the set of keys from the javadoc resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_javadoc = Layer.boot().findModule("jdk.javadoc").get();
+        Module jdk_javadoc = ModuleLayer.boot().findModule("jdk.javadoc").get();
         String[] names = {
                 "com.sun.tools.doclets.formats.html.resources.standard",
                 "com.sun.tools.doclets.internal.toolkit.resources.doclets",