changeset 4290:03ab1221ab9e

Merge
author mchung
date Thu, 08 Sep 2016 18:25:04 -0700
parents 898ed6a0367f a1502e7ec4f9
children 17508720b146
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java test/jdk/jshell/CompletionSuggestionTest.java test/tools/javac/diags/examples/DuplicateExports/exported/Class.java test/tools/javac/diags/examples/DuplicateExports/module-info.java test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/impl/ServiceImplementation.java test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/module-info.java test/tools/javac/modules/RequiresPublicTest.java test/tools/javac/modules/RequiresStaticTest.java test/tools/javac/options/release/ReleaseOptionClashes.java test/tools/jdeps/modules/src/m1/module-info.java test/tools/jdeps/modules/src/m1/p1/Goo.java test/tools/jdeps/modules/src/m1/p1/Lib.java test/tools/jdeps/modules/src/m1/p1/S.java test/tools/jdeps/modules/src/m1/p1/internal/Impl.java test/tools/jdeps/modules/src/m2/module-info.java test/tools/jdeps/modules/src/m2/p2/Bar.java test/tools/jdeps/modules/src/m2/p2/internal/T2.java test/tools/jdeps/modules/src/m3/module-info.java test/tools/jdeps/modules/src/m3/p3/Foo.java test/tools/jdeps/modules/src/m3/p3/Main.java test/tools/lib/toolbox/ModuleBuilder.java
diffstat 107 files changed, 1863 insertions(+), 1360 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Thu Sep 08 18:25:04 2016 -0700
@@ -96,7 +96,7 @@
      * @since 9
      */
     enum DirectiveKind {
-        /** A "requires [public] module-name" directive. */
+        /** A "requires (static|transitive)* module-name" directive. */
         REQUIRES,
         /** An "exports package-name [to module-name-list]" directive. */
         EXPORTS,
@@ -127,10 +127,16 @@
      */
     interface RequiresDirective extends Directive {
         /**
-         * Returns whether or not this is a public dependency.
-         * @return whether or not this is a public dependency
+         * Returns whether or not this is a static dependency.
+         * @return whether or not this is a static dependency
          */
-        boolean isPublic();
+        boolean isStatic();
+
+        /**
+         * Returns whether or not this is a transitive dependency.
+         * @return whether or not this is a transitive dependency
+         */
+        boolean isTransitive();
 
         /**
          * Returns the module that is required
@@ -144,8 +150,15 @@
      * @since 9
      */
     interface ExportsDirective extends Directive {
+
         /**
-         * Returns the package being exported.
+         * Returns whether or not this is a private exports.
+         * @return whether or not this is a private exports
+         */
+        boolean isPrivate();
+
+        /**
+         * Returns the package being exported, or null if this is a default exports directive.
          * @return the package being exported
          */
         PackageElement getPackage();
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/ExportsTree.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ExportsTree.java	Thu Sep 08 18:25:04 2016 -0700
@@ -34,13 +34,22 @@
  * <pre>
  *    exports <em>package-name</em>;
  *    exports <em>package-name</em> to <em>module-name</em>;
+ *    exports dynamic <em>package-name</em> to <em>module-name</em>;
+ *    exports private <em>package-name</em> to <em>module-name</em>;
  * </pre>
  *
  * @since 9
  */
 public interface ExportsTree extends DirectiveTree {
+
     /**
-     * Returns the name of the package to be exported.
+     * Returns true if this is a "exports private" directive.
+     * @return true if this is a "exports private" directive
+     */
+    boolean isPrivate();
+
+    /**
+     * Returns the name of the package to be exported, or null if this is a default exports directive.
      * @return  the name of the package to be exported
      */
     ExpressionTree getExportName();
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/ModuleTree.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ModuleTree.java	Thu Sep 08 18:25:04 2016 -0700
@@ -33,7 +33,8 @@
  *
  * For example:
  * <pre>
- *    module <em>module-name</em> {
+ *    <em>annotations</em>
+ *    [weak] module <em>module-name</em> {
  *        <em>directives</em>
  *    }
  * </pre>
@@ -48,6 +49,12 @@
     List<? extends AnnotationTree> getAnnotations();
 
     /**
+     * Returns true if this is a "weak" module.
+     * @return true if this is a "weak" module
+     */
+    boolean isWeak();
+
+    /**
      * Returns the name of the module.
      * @return the name of the module
      */
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/RequiresTree.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/RequiresTree.java	Thu Sep 08 18:25:04 2016 -0700
@@ -31,17 +31,24 @@
  * For example:
  * <pre>
  *    requires <em>module-name</em>;
- *    requires public <em>module-name</em>;
+ *    requires static <em>module-name</em>;
+ *    requires transitive <em>module-name</em>;
  * </pre>
  *
  * @since 9
  */
 public interface RequiresTree extends DirectiveTree {
     /**
-     * Returns true if this is a "requires public" directive.
-     * @return true if this is a "requires public" directive
+     * Returns true if this is a "requires static" directive.
+     * @return true if this is a "requires static" directive
      */
-    boolean isPublic();
+    boolean isStatic();
+
+    /**
+     * Returns true if this is a "requires transitive" directive.
+     * @return true if this is a "requires transitive" directive
+     */
+    boolean isTransitive();
 
     /**
      * Returns the name of the module that is required.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Thu Sep 08 18:25:04 2016 -0700
@@ -541,7 +541,7 @@
     // One plausible solution is to detect if the module's sourceLocation
     // is the same as the module's classLocation.
     private void scanModulePaths(PackageSymbol p, ModuleSymbol msym) throws IOException {
-        Set<JavaFileObject.Kind> kinds = getPackageFileKinds();
+        Set<JavaFileObject.Kind> kinds = EnumSet.allOf(JavaFileObject.Kind.class);//getPackageFileKinds();
 
         Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
         classKinds.remove(JavaFileObject.Kind.SOURCE);
@@ -576,7 +576,7 @@
      * Scans class path and source path for files in given package.
      */
     private void scanUserPaths(PackageSymbol p, boolean includeSourcePath) throws IOException {
-        Set<JavaFileObject.Kind> kinds = getPackageFileKinds();
+        Set<JavaFileObject.Kind> kinds = EnumSet.allOf(JavaFileObject.Kind.class);//getPackageFileKinds();
 
         Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
         classKinds.remove(JavaFileObject.Kind.SOURCE);
@@ -666,6 +666,7 @@
                                       allowSigFiles &&
                                       fo.getName().endsWith(".sig");
                     if (!sigFile) {
+                        p.flags_field |= Flags.HAS_RESOURCE;
                         extraFileActions(p, fo);
                         break;
                     }
@@ -681,7 +682,9 @@
                     break;
                 }
                 default:
+                    p.flags_field |= Flags.HAS_RESOURCE;
                     extraFileActions(p, fo);
+                    break;
                 }
             }
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java	Thu Sep 08 18:25:04 2016 -0700
@@ -76,7 +76,9 @@
 
     /** Flags for ExportsDirective. */
     public enum ExportsFlag {
-        DYNAMIC_PHASE(0x0040);
+        REFLECTION(0x0080),
+        SYNTHETIC(0x1000),
+        MANDATED(0x8000);
 
         // overkill? move to ClassWriter?
         public static int value(Set<ExportsFlag> s) {
@@ -98,7 +100,7 @@
      */
     public static class ExportsDirective extends Directive
             implements ModuleElement.ExportsDirective {
-        public final PackageSymbol packge;
+        public final PackageSymbol packge;  // null for default
         public final Set<ExportsFlag> flags;
         public final List<ModuleSymbol> modules;
 
@@ -118,6 +120,11 @@
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
+        public boolean isPrivate() {
+            return flags.contains(ExportsFlag.REFLECTION);
+        }
+
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public PackageElement getPackage() {
             return packge;
         }
@@ -187,7 +194,7 @@
     }
 
     /**
-     * 'requires' ['public'] ModuleName ';'
+     * 'requires' ('static' | 'transitive')* ModuleName ';'
      */
     public static class RequiresDirective extends Directive
             implements ModuleElement.RequiresDirective {
@@ -209,7 +216,12 @@
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
-        public boolean isPublic() {
+        public boolean isStatic() {
+            return flags.contains(RequiresFlag.STATIC_PHASE);
+        }
+
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
+        public boolean isTransitive() {
             return flags.contains(RequiresFlag.TRANSITIVE);
         }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Sep 08 18:25:04 2016 -0700
@@ -293,6 +293,11 @@
      */
     public static final long SYSTEM_MODULE = 1L<<53;
 
+    /**
+     * Flag to indicate the given PackageSymbol contains any non-.java and non-.class resources.
+     */
+    public static final long HAS_RESOURCE = 1L<<54;
+
     /** Modifier masks.
      */
     public static final int
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Sep 08 18:25:04 2016 -0700
@@ -27,7 +27,9 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.annotation.Inherited;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
@@ -47,6 +49,7 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.ClassFinder.BadEnclosingMethodAttr;
+import com.sun.tools.javac.code.Directive.RequiresFlag;
 import com.sun.tools.javac.code.Kinds.Kind;
 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
 import com.sun.tools.javac.code.Scope.WriteableScope;
@@ -910,9 +913,11 @@
 
         public PackageSymbol unnamedPackage;
         public Map<Name, PackageSymbol> visiblePackages;
+        public Collection<ModuleSymbol> readModules;
         public List<Symbol> enclosedPackages = List.nil();
 
         public Completer usesProvidesCompleter = Completer.NULL_COMPLETER;
+        public final Set<ModuleFlags> flags = EnumSet.noneOf(ModuleFlags.class);
 
         /**
          * Create a ModuleSymbol with an associated module-info ClassSymbol.
@@ -1002,6 +1007,27 @@
 
     }
 
+    public enum ModuleFlags {
+        WEAK(0x0020),
+        SYNTHETIC(0x1000),
+        MANDATED(0x8000);
+
+        // XXX: also in Directive.RequiresFlag, should unify!
+        public static int value(Set<ModuleFlags> s) {
+            int v = 0;
+            for (ModuleFlags f: s)
+                v |= f.value;
+            return v;
+        }
+
+        private ModuleFlags(int value) {
+            this.value = value;
+        }
+
+        public final int value;
+
+    }
+
     /** A class for package symbols
      */
     public static class PackageSymbol extends TypeSymbol
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Sep 08 18:25:04 2016 -0700
@@ -31,6 +31,7 @@
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.lang.model.element.ElementVisitor;
 
@@ -65,6 +66,7 @@
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.code.Symbol.ModuleFlags;
 import static com.sun.tools.javac.code.TypeTag.*;
 
 /** A class that defines all predefined constants and operators
@@ -463,6 +465,7 @@
             java_base = enterModule(names.java_base);
             //avoid completing java.base during the Symtab initialization
             java_base.completer = Completer.NULL_COMPLETER;
+            java_base.readModules = Collections.emptyList();
             java_base.visiblePackages = Collections.emptyMap();
         } else {
             java_base = noModule;
@@ -642,32 +645,27 @@
         if (pack != null && pack.exists())
             return pack;
 
-        boolean dependsOnUnnamed = msym.requires != null &&
-                                   msym.requires.stream()
-                                                .map(rd -> rd.module)
-                                                .anyMatch(mod -> mod == unnamedModule);
+        Collection<ModuleSymbol> unfilledModules =
+                msym.readModules.stream()
+                                .filter(mod -> mod == unnamedModule || mod.flags.contains(ModuleFlags.WEAK))
+                                .collect(Collectors.toList());
 
-        if (dependsOnUnnamed) {
-            //msyms depends on the unnamed module, for which we generally don't know
+        if (!unfilledModules.isEmpty()) {
+            //msyms depends on an "unfilled" module (unnamed or weak), for which we generally don't know
             //the list of packages it "exports" ahead of time. So try to lookup the package in the
-            //current module, and in the unnamed module and see if it exists in one of them
-            PackageSymbol unnamedPack = getPackage(unnamedModule, flatName);
-
-            if (unnamedPack != null && unnamedPack.exists()) {
-                msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
-                return unnamedPack;
-            }
-
+            //current module, and in the unfilled modules and see if it exists in any of them
             pack = enterPackage(msym, flatName);
             pack.complete();
             if (pack.exists())
                 return pack;
 
-            unnamedPack = enterPackage(unnamedModule, flatName);
-            unnamedPack.complete();
-            if (unnamedPack.exists()) {
-                msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
-                return unnamedPack;
+            for (ModuleSymbol unfilled : unfilledModules) {
+                PackageSymbol unfilledPack = enterPackage(unfilled, flatName);
+                unfilledPack.complete();
+                if (unfilledPack.exists()) {
+                    msym.visiblePackages.put(unfilledPack.fullname, unfilledPack);
+                    return unfilledPack;
+                }
             }
 
             return pack;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java	Thu Sep 08 18:25:04 2016 -0700
@@ -74,6 +74,11 @@
      */
     boolean isNewClass = false;
 
+    /**
+     *  Should access modifiers be ignored?
+     */
+    boolean ignoreAccessModifiers = false;
+
     /** Are arguments to current function applications boxed into an array for varargs?
      */
     Resolve.MethodResolutionPhase pendingResolutionPhase = null;
@@ -120,6 +125,7 @@
         info.isSpeculative = isSpeculative;
         info.isAnonymousDiamond = isAnonymousDiamond;
         info.isNewClass = isNewClass;
+        info.ignoreAccessModifiers = ignoreAccessModifiers;
         info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
         return info;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Sep 08 18:25:04 2016 -0700
@@ -109,7 +109,7 @@
 
 import static com.sun.tools.javac.code.Flags.ABSTRACT;
 import static com.sun.tools.javac.code.Flags.ENUM;
-import static com.sun.tools.javac.code.Flags.PUBLIC;
+import com.sun.tools.javac.code.Symbol.ModuleFlags;
 
 /**
  *  TODO: fill in
@@ -600,12 +600,16 @@
     class ModuleVisitor extends JCTree.Visitor {
         private ModuleSymbol sym;
         private final Set<ModuleSymbol> allRequires = new HashSet<>();
-        private final Set<PackageSymbol> allExports = new HashSet<>();
+        private final Map<PackageSymbol,List<ExportsDirective>> allExports = new HashMap<>();
 
         @Override
         public void visitModuleDef(JCModuleDecl tree) {
             sym = Assert.checkNonNull(tree.sym);
 
+            if (tree.weak) {
+                sym.flags.add(ModuleFlags.WEAK);
+            }
+
             sym.requires = List.nil();
             sym.exports = List.nil();
             tree.directives.forEach(t -> t.accept(this));
@@ -636,11 +640,18 @@
 
         @Override
         public void visitExports(JCExports tree) {
+            PackageSymbol packge;
+
             Name name = TreeInfo.fullName(tree.qualid);
-            PackageSymbol packge = syms.enterPackage(sym, name);
+            packge = syms.enterPackage(sym, name);
             attr.setPackageSymbols(tree.qualid, packge);
-            if (!allExports.add(packge)) {
-                log.error(tree.qualid.pos(), Errors.DuplicateExports(packge));
+
+            if (sym.flags.contains(ModuleFlags.WEAK)) {
+                log.error(tree.pos(), Errors.NoExportsInWeak);
+            }
+            List<ExportsDirective> exportsForPackage = allExports.computeIfAbsent(packge, p -> List.nil());
+            for (ExportsDirective d : exportsForPackage) {
+                checkDuplicateExports(tree, packge, d);
             }
 
             List<ModuleSymbol> toModules = null;
@@ -650,22 +661,82 @@
                     ModuleSymbol msym = lookupModule(n);
                     if (msym.kind != MDL) {
                         log.error(n.pos(), Errors.ModuleNotFound(msym));
-                    } else if (!to.add(msym)) {
-                        log.error(n.pos(), Errors.DuplicateExports(msym));
+                    } else {
+                        for (ExportsDirective d : exportsForPackage) {
+                            checkDuplicateExportsToModule(n, msym, d);
+                        }
+                        if (!to.add(msym)) {
+                            reportExportConflictToModule(n, msym);
+                        }
                     }
                 }
                 toModules = List.from(to);
             }
 
             if (toModules == null || !toModules.isEmpty()) {
-                Set<ExportsFlag> flags = tree.isDynamicPhase
-                        ? EnumSet.of(ExportsFlag.DYNAMIC_PHASE) : Collections.emptySet();
+                Set<ExportsFlag> flags = EnumSet.noneOf(ExportsFlag.class);
+                if (tree.isPrivate) {
+                    flags.add(ExportsFlag.REFLECTION);
+                }
                 ExportsDirective d = new ExportsDirective(packge, toModules, flags);
                 tree.directive = d;
                 sym.exports = sym.exports.prepend(d);
+
+                allExports.put(packge, exportsForPackage.prepend(d));
             }
         }
 
+        /**
+         * Check if an exports tree conflicts with an earlier exports, represented by an exports directive
+         * @param tree the tree to check
+         * @param packge the package being exported, or null for exports default
+         * @param d the directive to compare against
+         */
+        private void checkDuplicateExports(JCExports tree, PackageSymbol packge, ExportsDirective d) {
+            if (tree.moduleNames == null) {
+                if (d.modules == null) {
+                    // both are unqualified: error
+                    reportExportConflict(tree, packge);
+                } else {
+                    // tree unqualified, directive qualified:
+                    // error if directive (i.e. qualified) does not add private
+                    if (tree.isPrivate || !d.isPrivate()) {
+                        reportExportConflict(tree, packge);
+                    }
+                }
+            } else {
+                if (d.modules == null) {
+                    // tree qualified, directive unqualified:
+                    // error if tree (i.e. qualified) does not add private
+                    if (d.isPrivate() || !tree.isPrivate) {
+                        reportExportConflict(tree, packge);
+                    }
+                } else {
+                    // both are qualified: error
+                    reportExportConflict(tree, packge);
+                }
+            }
+        }
+
+        private void reportExportConflict(JCExports tree, PackageSymbol packge) {
+            log.error(tree.qualid.pos(), Errors.ConflictingExports(packge));
+        }
+
+        private void checkDuplicateExportsToModule(JCExpression name, ModuleSymbol msym,
+                ExportsDirective d) {
+            if (d.modules != null) {
+                for (ModuleSymbol other : d.modules) {
+                    if (msym == other) {
+                        reportExportConflictToModule(name, msym);
+                    }
+                }
+            }
+        }
+
+        private void reportExportConflictToModule(JCExpression name, ModuleSymbol msym) {
+            log.error(name.pos(), Errors.ConflictingExportsToModule(msym));
+        }
+
         @Override
         public void visitProvides(JCProvides tree) { }
 
@@ -689,15 +760,10 @@
         }
 
         private ModuleSymbol lookupModule(JCExpression moduleName) {
-            try {
             Name name = TreeInfo.fullName(moduleName);
             ModuleSymbol msym = moduleFinder.findModule(name);
             TreeInfo.setSymbol(moduleName, msym);
             return msym;
-            } catch (Throwable t) {
-                System.err.println("Module " + sym + "; lookup export " + moduleName);
-                throw t;
-            }
         }
     }
 
@@ -750,7 +816,8 @@
 
         @Override
         public void visitExports(JCExports tree) {
-            if (tree.directive.packge.members().isEmpty()) {
+            if (tree.directive.packge.members().isEmpty() &&
+                (!tree.directive.isPrivate() || (tree.directive.packge.flags() & Flags.HAS_RESOURCE) == 0)) {
                 log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
             }
             msym.directives = msym.directives.prepend(tree.directive);
@@ -771,7 +838,14 @@
         @Override
         public void visitProvides(JCProvides tree) {
             Type st = attr.attribType(tree.serviceName, env, syms.objectType);
-            Type it = attr.attribType(tree.implName, env, syms.objectType);
+            boolean prevIgnoreAccessModifiers = env.info.ignoreAccessModifiers;
+            Type it;
+            try {
+                env.info.ignoreAccessModifiers = true;
+                it = attr.attribType(tree.implName, env, syms.objectType);
+            } finally {
+                env.info.ignoreAccessModifiers = prevIgnoreAccessModifiers;
+            }
             ClassSymbol service = (ClassSymbol) st.tsym;
             ClassSymbol impl = (ClassSymbol) it.tsym;
             if (!types.isSubtype(it, st)) {
@@ -787,8 +861,6 @@
                 MethodSymbol constr = noArgsConstructor(impl);
                 if (constr == null) {
                     log.error(tree.implName.pos(), Errors.ServiceImplementationDoesntHaveANoArgsConstructor(impl));
-                } else if ((constr.flags() & PUBLIC) == 0) {
-                    log.error(tree.implName.pos(), Errors.ServiceImplementationNoArgsConstructorNotPublic(impl));
                 }
             }
             if (st.hasTag(CLASS) && it.hasTag(CLASS)) {
@@ -1013,7 +1085,8 @@
             @Override
             public void complete(Symbol sym) throws CompletionFailure {
                 ModuleSymbol msym = (ModuleSymbol) sym;
-                Set<ModuleSymbol> allModules = allModules();
+                Set<ModuleSymbol> allModules = new HashSet<>(allModules());
+                allModules.remove(syms.unnamedModule);
                 for (ModuleSymbol m : allModules) {
                     m.complete();
                 }
@@ -1027,7 +1100,7 @@
         };
     }
 
-    private final Map<ModuleSymbol, Set<ModuleSymbol>> requiresPublicCache = new HashMap<>();
+    private final Map<ModuleSymbol, Set<ModuleSymbol>> requiresTransitiveCache = new HashMap<>();
 
     private void completeModule(ModuleSymbol msym) {
         if (inInitModules) {
@@ -1073,34 +1146,36 @@
         }
 
         Set<ModuleSymbol> readable = new LinkedHashSet<>();
-        Set<ModuleSymbol> requiresPublic = new HashSet<>();
+        Set<ModuleSymbol> requiresTransitive = new HashSet<>();
 
         for (RequiresDirective d : msym.requires) {
             d.module.complete();
             readable.add(d.module);
-            Set<ModuleSymbol> s = retrieveRequiresPublic(d.module);
+            Set<ModuleSymbol> s = retrieveRequiresTransitive(d.module);
             Assert.checkNonNull(s, () -> "no entry in cache for " + d.module);
             readable.addAll(s);
             if (d.flags.contains(RequiresFlag.TRANSITIVE)) {
-                requiresPublic.add(d.module);
-                requiresPublic.addAll(s);
+                requiresTransitive.add(d.module);
+                requiresTransitive.addAll(s);
             }
         }
 
-        requiresPublicCache.put(msym, requiresPublic);
+        requiresTransitiveCache.put(msym, requiresTransitive);
         initVisiblePackages(msym, readable);
         for (ExportsDirective d: msym.exports) {
-            d.packge.modle = msym;
+            if (d.packge != null) {
+                d.packge.modle = msym;
+            }
         }
 
     }
 
-    private Set<ModuleSymbol> retrieveRequiresPublic(ModuleSymbol msym) {
-        Set<ModuleSymbol> requiresPublic = requiresPublicCache.get(msym);
+    private Set<ModuleSymbol> retrieveRequiresTransitive(ModuleSymbol msym) {
+        Set<ModuleSymbol> requiresTransitive = requiresTransitiveCache.get(msym);
 
-        if (requiresPublic == null) {
+        if (requiresTransitive == null) {
             //the module graph may contain cycles involving automatic modules or --add-reads edges
-            requiresPublic = new HashSet<>();
+            requiresTransitive = new HashSet<>();
 
             Set<ModuleSymbol> seen = new HashSet<>();
             List<ModuleSymbol> todo = List.of(msym);
@@ -1110,14 +1185,14 @@
                 todo = todo.tail;
                 if (!seen.add(current))
                     continue;
-                requiresPublic.add(current);
+                requiresTransitive.add(current);
                 current.complete();
                 Iterable<? extends RequiresDirective> requires;
                 if (current != syms.unnamedModule) {
                     Assert.checkNonNull(current.requires, () -> current + ".requires == null; " + msym);
                     requires = current.requires;
                     for (RequiresDirective rd : requires) {
-                        if (rd.isPublic())
+                        if (rd.isTransitive())
                             todo = todo.prepend(rd.module);
                     }
                 } else {
@@ -1127,15 +1202,16 @@
                 }
             }
 
-            requiresPublic.remove(msym);
+            requiresTransitive.remove(msym);
         }
 
-        return requiresPublic;
+        return requiresTransitive;
     }
 
     private void initVisiblePackages(ModuleSymbol msym, Collection<ModuleSymbol> readable) {
         initAddExports();
 
+        msym.readModules = readable;
         msym.visiblePackages = new LinkedHashMap<>();
 
         Map<Name, ModuleSymbol> seen = new HashMap<>();
@@ -1155,11 +1231,6 @@
                                     ModuleSymbol exportsFrom,
                                     Collection<ExportsDirective> exports) {
         for (ExportsDirective d : exports) {
-            // "exports dynamic ..." are not effective at compile-time
-            if (d.flags.contains(ExportsFlag.DYNAMIC_PHASE)) {
-                continue;
-            }
-
             if (d.modules == null || d.modules.contains(msym)) {
                 Name packageName = d.packge.fullname;
                 ModuleSymbol previousModule = seenPackages.get(packageName);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Sep 08 18:25:04 2016 -0700
@@ -304,8 +304,10 @@
         if (env.enclMethod != null && (env.enclMethod.mods.flags & ANONCONSTR) != 0)
             return true;
 
-        boolean isAccessible = false;
-        switch ((short)(c.flags() & AccessFlags)) {
+        boolean isAccessible;
+        short accessFlag = !env.info.ignoreAccessModifiers ?
+                (short)(c.flags() & AccessFlags) : PUBLIC;
+        switch (accessFlag) {
             case PRIVATE:
                 isAccessible =
                     env.enclClass.sym.outermostClass() ==
@@ -321,7 +323,6 @@
                 isAccessible = true;
                 break;
             case PUBLIC:
-                isAccessible = true;
                 if (allowModules && checkModuleAccess) {
                     ModuleSymbol currModule = env.toplevel.modle;
                     currModule.complete();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1080,7 +1080,8 @@
                     }
 
                     // finally clean up the module name
-                    mn =  mn.replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
+                    mn =  mn.replaceAll("(\\.|\\d)*$", "")    // remove trailing version
+                            .replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
                             .replaceAll("(\\.)(\\1)+", ".")   // collapse repeating dots
                             .replaceAll("^\\.", "")           // drop leading dots
                             .replaceAll("\\.$", "");          // drop trailing dots
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 08 18:25:04 2016 -0700
@@ -583,6 +583,17 @@
         throw badClassFile("bad.module-info.name");
     }
 
+    /** Read module_flags.
+     */
+    Set<ModuleFlags> readModuleFlags(int flags) {
+        Set<ModuleFlags> set = EnumSet.noneOf(ModuleFlags.class);
+        for (ModuleFlags f : ModuleFlags.values()) {
+            if ((flags & f.value) != 0)
+                set.add(f);
+        }
+        return set;
+    }
+
     /** Read exports_flags.
      */
     Set<ExportsFlag> readExportsFlags(int flags) {
@@ -1240,6 +1251,8 @@
                         ModuleSymbol msym = (ModuleSymbol) sym.owner;
                         ListBuffer<Directive> directives = new ListBuffer<>();
 
+                        msym.flags.addAll(readModuleFlags(nextChar()));
+
                         ListBuffer<RequiresDirective> requires = new ListBuffer<>();
                         int nrequires = nextChar();
                         for (int i = 0; i < nrequires; i++) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Sep 08 18:25:04 2016 -0700
@@ -952,6 +952,8 @@
         ModuleSymbol m = (ModuleSymbol) c.owner;
 
         int alenIdx = writeAttr(names.Module);
+        databuf.appendChar(ModuleFlags.value(m.flags)); // module_flags
+
         ListBuffer<RequiresDirective> requires = new ListBuffer<>();
         for (RequiresDirective r: m.requires) {
             if (!r.flags.contains(RequiresFlag.EXTRA))
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Sep 08 18:25:04 2016 -0700
@@ -51,7 +51,6 @@
 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.LT;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
 
 /** The parser maps a token sequence into an abstract syntax
  *  tree. It operates by recursive descent, with code derived
@@ -3150,16 +3149,25 @@
                 }
                 if (mods != null || token.kind != SEMI)
                     mods = modifiersOpt(mods);
-                if (token.kind == IDENTIFIER && token.name() == names.module && firstTypeDecl) {
-                    List<JCAnnotation> annotations = List.nil();
-                    if (mods != null) {
-                        checkNoMods(mods.flags);
-                        annotations = mods.annotations;
-                        mods = null;
+                if (firstTypeDecl && token.kind == IDENTIFIER) {
+                    boolean weak = false;
+                    if (token.name() == names.weak) {
+                        weak = true;
+                        nextToken();
                     }
-                    defs.append(moduleDecl(annotations, docComment));
-                    consumedToplevelDoc = true;
-                    break;
+                    if (token.kind == IDENTIFIER && token.name() == names.module) {
+                        List<JCAnnotation> annotations = List.nil();
+                        if (mods != null) {
+                            checkNoMods(mods.flags);
+                            annotations = mods.annotations;
+                            mods = null;
+                        }
+                        defs.append(moduleDecl(annotations, weak, docComment));
+                        consumedToplevelDoc = true;
+                        break;
+                    } else if (weak) {
+                        reportSyntaxError(token.pos, "expected.module");
+                    }
                 }
                 JCTree def = typeDeclaration(mods, docComment);
                 if (def instanceof JCExpressionStatement)
@@ -3185,7 +3193,7 @@
         return toplevel;
     }
 
-    JCModuleDecl moduleDecl(List<JCAnnotation> annotations, Comment dc) {
+    JCModuleDecl moduleDecl(List<JCAnnotation> annotations, boolean weak, Comment dc) {
         int pos = token.pos;
         if (!allowModules) {
             log.error(pos, Errors.ModulesNotSupportedInSource(source.name));
@@ -3201,7 +3209,7 @@
         accept(RBRACE);
         accept(EOF);
 
-        JCModuleDecl result = toP(F.at(pos).ModuleDef(annotations, name, directives));
+        JCModuleDecl result = toP(F.at(pos).ModuleDef(annotations, weak, name, directives));
         attach(result, dc);
         return result;
     }
@@ -3212,16 +3220,31 @@
             int pos = token.pos;
             if (token.name() == names.requires) {
                 nextToken();
+                boolean isPublic = false;
                 boolean isTransitive = false;
                 boolean isStaticPhase = false;
             loop:
                 while (true) {
                     switch (token.kind) {
-                        case PUBLIC:
-                            if (isTransitive) {
+                        case IDENTIFIER:
+                            if (token.name() == names.transitive && !isTransitive) {
+                                Token t1 = S.token(1);
+                                if (t1.kind == SEMI || t1.kind == DOT) {
+                                    break loop;
+                                }
+                                if (isPublic) { // temporary
+                                    error(token.pos, "repeated.modifier");
+                                }
+                                isTransitive = true;
+                                break;
+                            } else {
+                                break loop;
+                            }
+                        case PUBLIC: // temporary
+                            if (isPublic || isTransitive) {
                                 error(token.pos, "repeated.modifier");
                             }
-                            isTransitive = true;
+                            isPublic = isTransitive = true;
                             break;
                         case STATIC:
                             if (isStaticPhase) {
@@ -3239,19 +3262,14 @@
                 defs.append(toP(F.at(pos).Requires(isTransitive, isStaticPhase, moduleName)));
             } else if (token.name() == names.exports) {
                 nextToken();
-                boolean isDynamicPhase = false;
-                if (token.kind == IDENTIFIER && token.name() == names.dynamic) {
-                    // lookahead to see if dynamic is followed by a package name
-                    // (or if the token is itself the beginning of a package name)
-                    Token t1 = S.token(1);
-                    Token t2 = S.token(2);
-                    if (t1.kind == IDENTIFIER
-                            && (t2.kind == SEMI
-                                || t2.kind == DOT
-                                || t2.kind == IDENTIFIER && t2.name() == names.to)) {
-                        isDynamicPhase = true;
-                        nextToken();
+                boolean isPrivate = false;
+            loop:
+                while (token.kind == PRIVATE) {
+                    if (isPrivate) {
+                        error(token.pos, "repeated.modifier");
                     }
+                    isPrivate = true;
+                    nextToken();
                 }
                 JCExpression pkgName = qualident(false);
                 List<JCExpression> moduleNames = null;
@@ -3260,7 +3278,7 @@
                     moduleNames = qualidentList(false);
                 }
                 accept(SEMI);
-                defs.append(toP(F.at(pos).Exports(pkgName, isDynamicPhase, moduleNames)));
+                defs.append(toP(F.at(pos).Exports(pkgName, isPrivate, moduleNames)));
             } else if (token.name() == names.provides) {
                 nextToken();
                 JCExpression serviceName = qualident(false);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 08 18:25:04 2016 -0700
@@ -1775,6 +1775,9 @@
     reached end of file while parsing
 
 ## The following are related in form, but do not easily fit the above paradigm.
+compiler.err.expected.module=\
+    ''module'' expected
+
 compiler.err.dot.class.expected=\
     ''.class'' expected
 
@@ -2722,8 +2725,15 @@
     duplicate requires: {0}
 
 # 0: symbol
-compiler.err.duplicate.exports=\
-    duplicate export: {0}
+compiler.err.conflicting.exports=\
+    duplicate or conflicting exports: {0}
+
+# 0: symbol
+compiler.err.conflicting.exports.to.module=\
+    duplicate or conflicting exports to module: {0}
+
+compiler.err.no.exports.in.weak=\
+    exports not allowed in weak modules
 
 # 0: symbol, 1: symbol
 compiler.err.duplicate.provides=\
@@ -2757,10 +2767,6 @@
     the service implementation does not have a default constructor: {0}
 
 # 0: symbol
-compiler.err.service.implementation.no.args.constructor.not.public=\
-    the no arguments constructor of the service implementation is not public: {0}
-
-# 0: symbol
 compiler.err.package.empty.or.not.found=\
     package is empty or does not exist: {0}
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 08 18:25:04 2016 -0700
@@ -2630,12 +2630,15 @@
 
     public static class JCModuleDecl extends JCTree implements ModuleTree {
         public List<JCAnnotation> annotations;
+        public boolean weak;
         public JCExpression qualId;
         public List<JCDirective> directives;
         public ModuleSymbol sym;
 
-        protected JCModuleDecl(List<JCAnnotation> annotations, JCExpression qualId, List<JCDirective> directives) {
+        protected JCModuleDecl(List<JCAnnotation> annotations, boolean weak,
+                JCExpression qualId, List<JCDirective> directives) {
             this.annotations = annotations;
+            this.weak = weak;
             this.qualId = qualId;
             this.directives = directives;
         }
@@ -2654,6 +2657,11 @@
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
+        public boolean isWeak() {
+            return weak;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getName() {
             return qualId;
         }
@@ -2676,14 +2684,14 @@
 
     public static class JCExports extends JCDirective
             implements ExportsTree {
-        public JCExpression qualid;
-        public boolean isDynamicPhase;
+        public JCExpression qualid; // null for default
+        public boolean isPrivate;
         public List<JCExpression> moduleNames;
         public ExportsDirective directive;
 
-        protected JCExports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
+        protected JCExports(JCExpression qualId, boolean isPrivate, List<JCExpression> moduleNames) {
             this.qualid = qualId;
-            this.isDynamicPhase = isDynamicPhase;
+            this.isPrivate = isPrivate;
             this.moduleNames = moduleNames;
         }
 
@@ -2691,6 +2699,11 @@
         public void accept(Visitor v) { v.visitExports(this); }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
+        public boolean isPrivate() {
+            return isPrivate;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.EXPORTS;
         }
@@ -2782,11 +2795,16 @@
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
-        public boolean isPublic() {
+        public boolean isTransitive() {
             return isTransitive;
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
+        public boolean isStatic() {
+            return isStaticPhase;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getModuleName() {
             return moduleName;
         }
@@ -2967,8 +2985,8 @@
         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
         JCErroneous Erroneous(List<? extends JCTree> errs);
-        JCModuleDecl ModuleDef(List<JCAnnotation> annotations, JCExpression qualId, List<JCDirective> directives);
-        JCExports Exports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames);
+        JCModuleDecl ModuleDef(List<JCAnnotation> annotations, boolean weak, JCExpression qualId, List<JCDirective> directives);
+        JCExports Exports(JCExpression qualId, boolean isPrivate, List<JCExpression> moduleNames);
         JCProvides Provides(JCExpression serviceName, JCExpression implName);
         JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
         JCUses Uses(JCExpression qualId);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Sep 08 18:25:04 2016 -0700
@@ -441,6 +441,10 @@
     @Override
     public void visitModuleDef(JCModuleDecl tree) {
         try {
+            printAnnotations(tree.annotations);
+            if (tree.isWeak()) {
+                print("weak ");
+            }
             print("module ");
             printExpr(tree.qualId);
             if (tree.directives == null) {
@@ -458,6 +462,8 @@
     public void visitExports(JCExports tree) {
         try {
             print("exports ");
+            if (tree.isPrivate)
+                print("private ");
             printExpr(tree.qualid);
             if (tree.moduleNames != null) {
                 print(" to ");
@@ -486,8 +492,10 @@
     public void visitRequires(JCRequires tree) {
         try {
             print("requires ");
+            if (tree.isStaticPhase)
+                print("static ");
             if (tree.isTransitive)
-                print("public ");
+                print("transitive ");
             printExpr(tree.moduleName);
             print(";");
         } catch (IOException e) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Sep 08 18:25:04 2016 -0700
@@ -511,7 +511,7 @@
         List<JCAnnotation> annotations = copy(t.annotations, p);
         JCExpression qualId = copy(t.qualId);
         List<JCDirective> directives = copy(t.directives);
-        return M.at(t.pos).ModuleDef(annotations, qualId, directives);
+        return M.at(t.pos).ModuleDef(annotations, t.weak, qualId, directives);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
@@ -519,7 +519,7 @@
         JCExports t = (JCExports) node;
         JCExpression qualId = copy(t.qualid, p);
         List<JCExpression> moduleNames = copy(t.moduleNames, p);
-        return M.at(t.pos).Exports(qualId, t.isDynamicPhase, moduleNames);
+        return M.at(t.pos).Exports(qualId, t.isPrivate, moduleNames);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -538,15 +538,16 @@
     }
 
     @Override
-    public JCModuleDecl ModuleDef(List<JCAnnotation> annotations, JCExpression qualid, List<JCDirective> directives) {
-        JCModuleDecl tree = new JCModuleDecl(annotations, qualid, directives);
+    public JCModuleDecl ModuleDef(List<JCAnnotation> annotations, boolean weak,
+            JCExpression qualid, List<JCDirective> directives) {
+        JCModuleDecl tree = new JCModuleDecl(annotations, weak, qualid, directives);
         tree.pos = pos;
         return tree;
     }
 
     @Override
-    public JCExports Exports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
-        JCExports tree = new JCExports(qualId, isDynamicPhase, moduleNames);
+    public JCExports Exports(JCExpression qualId, boolean isPrivate, List<JCExpression> moduleNames) {
+        JCExports tree = new JCExports(qualId, isPrivate, moduleNames);
         tree.pos = pos;
         return tree;
     }
@@ -559,8 +560,8 @@
     }
 
     @Override
-    public JCRequires Requires(boolean isPublic, boolean isStaticPhase, JCExpression qualId) {
-        JCRequires tree = new JCRequires(isPublic, isStaticPhase, qualId);
+    public JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId) {
+        JCRequires tree = new JCRequires(isTransitive, isStaticPhase, qualId);
         tree.pos = pos;
         return tree;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,9 @@
     public final Name provides;
     public final Name requires;
     public final Name to;
+    public final Name transitive;
     public final Name uses;
+    public final Name weak;
     public final Name with;
 
     // field and method names
@@ -226,7 +228,9 @@
         provides = fromString("provides");
         requires = fromString("requires");
         to = fromString("to");
+        transitive = fromString("transitive");
         uses = fromString("uses");
+        weak = fromString("weak");
         with = fromString("with");
 
         // field and method names
--- a/src/jdk.compiler/share/classes/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.compiler/share/classes/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,7 +28,7 @@
  *  and its command line equivalent, <em>javac</em>, as well as <em>javah</em>.
  */
 module jdk.compiler {
-    requires public java.compiler;
+    requires transitive java.compiler;
 
     exports com.sun.source.doctree;
     exports com.sun.source.tree;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Thu Sep 08 18:25:04 2016 -0700
@@ -505,10 +505,10 @@
     private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean isPublic) {
         Set<ModuleElement> result = new HashSet<>();
         for (RequiresDirective rd : ElementFilter.requiresIn(mdle.getDirectives())) {
-            if (isPublic && rd.isPublic()) {
+            if (isPublic && rd.isTransitive()) {
                 result.add(rd.getDependency());
             }
-            if (!isPublic && !rd.isPublic()) {
+            if (!isPublic && !rd.isTransitive()) {
                 result.add(rd.getDependency());
             }
         }
--- a/src/jdk.javadoc/share/classes/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.javadoc/share/classes/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,8 +28,8 @@
  *  and its command line equivalent, <em>javadoc</em>.
  */
 module jdk.javadoc {
-    requires public java.compiler;
-    requires public jdk.compiler;
+    requires transitive java.compiler;
+    requires transitive jdk.compiler;
     requires java.xml;
 
     exports com.sun.javadoc;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java	Thu Sep 08 18:25:04 2016 -0700
@@ -42,7 +42,6 @@
     public static final String BootstrapMethods         = "BootstrapMethods";
     public static final String CharacterRangeTable      = "CharacterRangeTable";
     public static final String Code                     = "Code";
-    public static final String ConcealedPackages        = "ConcealedPackages";
     public static final String ConstantValue            = "ConstantValue";
     public static final String CompilationID            = "CompilationID";
     public static final String Deprecated               = "Deprecated";
@@ -56,6 +55,7 @@
     public static final String MainClass                = "MainClass";
     public static final String MethodParameters         = "MethodParameters";
     public static final String Module                   = "Module";
+    public static final String Packages                 = "Packages";
     public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
     public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
     public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
@@ -115,7 +115,6 @@
             standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
             standardAttributes.put(Code,              Code_attribute.class);
             standardAttributes.put(CompilationID,     CompilationID_attribute.class);
-            standardAttributes.put(ConcealedPackages, ConcealedPackages_attribute.class);
             standardAttributes.put(ConstantValue,     ConstantValue_attribute.class);
             standardAttributes.put(Deprecated,        Deprecated_attribute.class);
             standardAttributes.put(EnclosingMethod,   EnclosingMethod_attribute.class);
@@ -128,6 +127,7 @@
             standardAttributes.put(MainClass,         MainClass_attribute.class);
             standardAttributes.put(MethodParameters,  MethodParameters_attribute.class);
             standardAttributes.put(Module,            Module_attribute.class);
+            standardAttributes.put(Packages,          Packages_attribute.class);
             standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
             standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
             standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
@@ -178,7 +178,6 @@
         R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p);
         R visitCode(Code_attribute attr, P p);
         R visitCompilationID(CompilationID_attribute attr, P p);
-        R visitConcealedPackages(ConcealedPackages_attribute attr, P p);
         R visitConstantValue(ConstantValue_attribute attr, P p);
         R visitDeprecated(Deprecated_attribute attr, P p);
         R visitEnclosingMethod(EnclosingMethod_attribute attr, P p);
@@ -191,6 +190,7 @@
         R visitMainClass(MainClass_attribute attr, P p);
         R visitMethodParameters(MethodParameters_attribute attr, P p);
         R visitModule(Module_attribute attr, P p);
+        R visitPackages(Packages_attribute attr, P p);
         R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
         R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
         R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Sep 08 18:25:04 2016 -0700
@@ -419,7 +419,7 @@
         }
 
         @Override
-        public Void visitConcealedPackages(ConcealedPackages_attribute attr, ClassOutputStream out) {
+        public Void visitPackages(Packages_attribute attr, ClassOutputStream out) {
             out.writeShort(attr.packages_count);
             for (int i: attr.packages_index)
                 out.writeShort(i);
@@ -541,6 +541,8 @@
 
         @Override
         public Void visitModule(Module_attribute attr, ClassOutputStream out) {
+            out.writeShort(attr.module_flags);
+
             out.writeShort(attr.requires.length);
             for (Module_attribute.RequiresEntry e: attr.requires) {
                 out.writeShort(e.requires_index);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.classfile;
-
-import java.io.IOException;
-
-/**
- * See JVMS, section 4.8.15.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class ConcealedPackages_attribute extends Attribute {
-    ConcealedPackages_attribute(ClassReader cr, int name_index, int length)
-            throws IOException {
-        super(name_index, length);
-        packages_count = cr.readUnsignedShort();
-        packages_index = new int[packages_count];
-        for (int i = 0; i < packages_count; i++)
-            packages_index[i] = cr.readUnsignedShort();
-    }
-
-    public ConcealedPackages_attribute(ConstantPool constant_pool,
-                                       int[] packages_index)
-            throws ConstantPoolException {
-        this(constant_pool.getUTF8Index(Attribute.ConcealedPackages),
-             packages_index);
-    }
-
-    public ConcealedPackages_attribute(int name_index,
-                                       int[] packages_index) {
-        super(name_index, 2 + packages_index.length * 2);
-        this.packages_count = packages_index.length;
-        this.packages_index = packages_index;
-    }
-
-    public String getPackage(int index, ConstantPool constant_pool) throws ConstantPoolException {
-        int package_index = packages_index[index];
-        return constant_pool.getUTF8Value(package_index);
-    }
-
-    @Override
-    public <R, D> R accept(Visitor<R, D> visitor, D data) {
-        return visitor.visitConcealedPackages(this, data);
-    }
-
-    public final int packages_count;
-    public final int[] packages_index;
-}
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,14 +36,16 @@
  *  deletion without notice.</b>
  */
 public class Module_attribute extends Attribute {
-    public static final int ACC_TRANSITIVE    =   0x10;
-    public static final int ACC_STATIC_PHASE  =   0x20;
-    public static final int ACC_DYNAMIC_PHASE =   0x40;
-    public static final int ACC_SYNTHETIC     = 0x1000;
-    public static final int ACC_MANDATED      = 0x8000;
+    public static final int ACC_TRANSITIVE      =   0x10;
+    public static final int ACC_STATIC_PHASE    =   0x20;
+    public static final int ACC_WEAK            =   0x20;
+    public static final int ACC_REFLECTION      =   0x80;
+    public static final int ACC_SYNTHETIC       = 0x1000;
+    public static final int ACC_MANDATED        = 0x8000;
 
     Module_attribute(ClassReader cr, int name_index, int length) throws IOException {
         super(name_index, length);
+        module_flags = cr.readUnsignedShort();
         requires_count = cr.readUnsignedShort();
         requires = new RequiresEntry[requires_count];
         for (int i = 0; i < requires_count; i++)
@@ -63,11 +65,13 @@
     }
 
     public Module_attribute(int name_index,
+            int module_flags,
             RequiresEntry[] requires,
             ExportsEntry[] exports,
             int[] uses,
             ProvidesEntry[] provides) {
         super(name_index, 2);
+        this.module_flags = module_flags;
         requires_count = requires.length;
         this.requires = requires;
         exports_count = exports.length;
@@ -89,6 +93,7 @@
         return visitor.visitModule(this, data);
     }
 
+    public final int module_flags;
     public final int requires_count;
     public final RequiresEntry[] requires;
     public final int exports_count;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Packages_attribute.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JVMS, section 4.8.15.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class Packages_attribute extends Attribute {
+    Packages_attribute(ClassReader cr, int name_index, int length)
+            throws IOException {
+        super(name_index, length);
+        packages_count = cr.readUnsignedShort();
+        packages_index = new int[packages_count];
+        for (int i = 0; i < packages_count; i++)
+            packages_index[i] = cr.readUnsignedShort();
+    }
+
+    public Packages_attribute(ConstantPool constant_pool,
+                              int[] packages_index)
+            throws ConstantPoolException {
+        this(constant_pool.getUTF8Index(Attribute.Packages),
+             packages_index);
+    }
+
+    public Packages_attribute(int name_index,
+                              int[] packages_index) {
+        super(name_index, 2 + packages_index.length * 2);
+        this.packages_count = packages_index.length;
+        this.packages_index = packages_index;
+    }
+
+    public String getPackage(int index, ConstantPool constant_pool) throws ConstantPoolException {
+        int package_index = packages_index[index];
+        return constant_pool.getUTF8Value(package_index);
+    }
+
+    @Override
+    public <R, D> R accept(Visitor<R, D> visitor, D data) {
+        return visitor.visitPackages(this, data);
+    }
+
+    public final int packages_count;
+    public final int[] packages_index;
+}
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Sep 08 18:25:04 2016 -0700
@@ -34,7 +34,6 @@
 import com.sun.tools.classfile.CharacterRangeTable_attribute.Entry;
 import com.sun.tools.classfile.Code_attribute;
 import com.sun.tools.classfile.CompilationID_attribute;
-import com.sun.tools.classfile.ConcealedPackages_attribute;
 import com.sun.tools.classfile.ConstantPool;
 import com.sun.tools.classfile.ConstantPoolException;
 import com.sun.tools.classfile.ConstantValue_attribute;
@@ -51,6 +50,7 @@
 import com.sun.tools.classfile.MainClass_attribute;
 import com.sun.tools.classfile.MethodParameters_attribute;
 import com.sun.tools.classfile.Module_attribute;
+import com.sun.tools.classfile.Packages_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
@@ -237,7 +237,7 @@
         return null;
     }
 
-    private String getJavaPackage(ConcealedPackages_attribute attr, int index) {
+    private String getJavaPackage(Packages_attribute attr, int index) {
         try {
             return getJavaName(attr.getPackage(index, constant_pool));
         } catch (ConstantPoolException e) {
@@ -246,8 +246,8 @@
     }
 
     @Override
-    public Void visitConcealedPackages(ConcealedPackages_attribute attr, Void ignore) {
-        println("ConcealedPackages: ");
+    public Void visitPackages(Packages_attribute attr, Void ignore) {
+        println("Packages: ");
         indent(+1);
         for (int i = 0; i < attr.packages_count; i++) {
             print("#" + attr.packages_index[i]);
@@ -540,9 +540,18 @@
         for (Module_attribute.ExportsEntry e: entries) {
             print("#" + e.exports_index + "," + String.format("%x", e.exports_flags));
             tab();
-            print("// " + constantWriter.stringValue(e.exports_index));
-            if ((e.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
-                print(" ACC_DYNAMIC_PHASE");
+            print("// ");
+            if (e.exports_index == 0) {
+                print("default");
+            } else {
+                print(constantWriter.stringValue(e.exports_index));
+            }
+            if ((e.exports_flags & Module_attribute.ACC_MANDATED) != 0)
+                print(" ACC_MANDATED");
+            if ((e.exports_flags & Module_attribute.ACC_SYNTHETIC) != 0)
+                print(" ACC_SYNTHETIC");
+            if ((e.exports_flags & Module_attribute.ACC_REFLECTION) != 0)
+                print(" ACC_PRIVATE_REFLECTION");
             if (e.exports_to_index.length == 0) {
                 println();
             } else {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Sep 08 18:25:04 2016 -0700
@@ -163,6 +163,10 @@
         writeModifiers(flags.getClassModifiers());
 
         if (classFile.access_flags.is(AccessFlags.ACC_MODULE) && name.endsWith(".module-info")) {
+            Attribute attr = classFile.attributes.get(Attribute.Module);
+            if (attr instanceof Module_attribute && (((Module_attribute) attr).module_flags & Module_attribute.ACC_WEAK) != 0) {
+                print("weak ");
+            }
             print("module ");
             print(name.replace(".module-info", ""));
         } else {
@@ -555,20 +559,21 @@
         Module_attribute m = (Module_attribute) attr;
         for (Module_attribute.RequiresEntry entry: m.requires) {
             print("requires");
-            if ((entry.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
-                print(" public");
             if ((entry.requires_flags & Module_attribute.ACC_STATIC_PHASE) != 0)
                 print(" static");
+            if ((entry.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
+                print(" transitive");
             print(" ");
             print(getUTF8Value(entry.requires_index).replace('/', '.'));
             println(";");
         }
 
         for (Module_attribute.ExportsEntry entry: m.exports) {
-            print("exports ");
+            print("exports");
+            if ((entry.exports_flags & Module_attribute.ACC_REFLECTION) != 0)
+                print(" private");
+            print(" ");
             print(getUTF8Value(entry.exports_index).replace('/', '.'));
-            if ((entry.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
-                print(" dynamic");
             boolean first = true;
             for (int i: entry.exports_to_index) {
                 String mname;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Thu Sep 08 18:25:04 2016 -0700
@@ -29,11 +29,9 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Deque;
-import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedDeque;
@@ -261,7 +259,7 @@
 
     public static enum Info {
         REQUIRES,
-        REQUIRES_PUBLIC,
+        REQUIRES_TRANSITIVE,
         EXPORTED_API,
         MODULE_PRIVATE,
         QUALIFIED_EXPORTED_API,
@@ -286,7 +284,7 @@
         @Override
         public String toString() {
             StringBuilder sb = new StringBuilder();
-            if (info != Info.REQUIRES && info != Info.REQUIRES_PUBLIC)
+            if (info != Info.REQUIRES && info != Info.REQUIRES_TRANSITIVE)
                 sb.append(source).append("/");
 
             sb.append(name);
@@ -323,7 +321,7 @@
      * Returns a graph of module dependences.
      *
      * Each Node represents a module and each edge is a dependence.
-     * No analysis on "requires public".
+     * No analysis on "requires transitive".
      */
     public Graph<Node> moduleGraph() {
         Graph.Builder<Node> builder = new Graph.Builder<>();
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Thu Sep 08 18:25:04 2016 -0700
@@ -388,10 +388,10 @@
         }
 
         static void printEdges(PrintWriter out, Graph<String> graph,
-                               String node, Set<String> requiresPublic) {
+                               String node, Set<String> requiresTransitive) {
             graph.adjacentNodes(node).forEach(dn -> {
                 String attr = dn.equals("java.base") ? REQUIRES_BASE
-                        : (requiresPublic.contains(dn) ? REEXPORTS : REQUIRES);
+                        : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
                 out.format("  \"%s\" -> \"%s\" [%s];%n", node, dn, attr);
             });
         }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java	Thu Sep 08 18:25:04 2016 -0700
@@ -242,7 +242,7 @@
             ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(m.name());
             requires.keySet().forEach(mn -> {
                 if (requires.get(mn).equals(Boolean.TRUE)) {
-                    builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.PUBLIC), mn);
+                    builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.TRANSITIVE), mn);
                 } else {
                     builder.requires(mn);
                 }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Thu Sep 08 18:25:04 2016 -0700
@@ -97,8 +97,8 @@
 
     public boolean run() throws IOException {
         try {
-            // compute "requires public" dependences
-            modules.values().forEach(ModuleDeps::computeRequiresPublic);
+            // compute "requires transitive" dependences
+            modules.values().forEach(ModuleDeps::computeRequiresTransitive);
 
             modules.values().forEach(md -> {
                 // compute "requires" dependences
@@ -114,7 +114,7 @@
 
     class ModuleDeps {
         final Module root;
-        Set<Module> requiresPublic;
+        Set<Module> requiresTransitive;
         Set<Module> requires;
         Map<String, Set<String>> unusedQualifiedExports;
 
@@ -123,15 +123,15 @@
         }
 
         /**
-         * Compute 'requires public' dependences by analyzing API dependencies
+         * Compute 'requires transitive' dependences by analyzing API dependencies
          */
-        private void computeRequiresPublic() {
-            // record requires public
-            this.requiresPublic = computeRequires(true)
+        private void computeRequiresTransitive() {
+            // record requires transitive
+            this.requiresTransitive = computeRequires(true)
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .collect(toSet());
 
-            trace("requires public: %s%n", requiresPublic);
+            trace("requires transitive: %s%n", requiresTransitive);
         }
 
         private void computeRequires() {
@@ -154,10 +154,10 @@
         }
 
         ModuleDescriptor descriptor() {
-            return descriptor(requiresPublic, requires);
+            return descriptor(requiresTransitive, requires);
         }
 
-        private ModuleDescriptor descriptor(Set<Module> requiresPublic,
+        private ModuleDescriptor descriptor(Set<Module> requiresTransitive,
                                             Set<Module> requires) {
 
             ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(root.name());
@@ -165,13 +165,13 @@
             if (!root.name().equals(JAVA_BASE))
                 builder.requires(Set.of(MANDATED), JAVA_BASE);
 
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
-                .forEach(mn -> builder.requires(Set.of(PUBLIC), mn));
+                .forEach(mn -> builder.requires(Set.of(TRANSITIVE), mn));
 
             requires.stream()
-                .filter(m -> !requiresPublic.contains(m))
+                .filter(m -> !requiresTransitive.contains(m))
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
                 .forEach(mn -> builder.requires(mn));
@@ -181,13 +181,13 @@
 
         ModuleDescriptor reduced() {
             Graph.Builder<Module> bd = new Graph.Builder<>();
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .forEach(m -> {
                     bd.addNode(m);
                     bd.addEdge(root, m);
                 });
 
-            // requires public graph
+            // requires transitive graph
             Graph<Module> rbg = bd.build().reduce();
 
             // transitive reduction
@@ -197,7 +197,7 @@
                 newGraph.printGraph(log);
             }
 
-            return descriptor(requiresPublic, newGraph.adjacentNodes(root));
+            return descriptor(requiresTransitive, newGraph.adjacentNodes(root));
         }
 
 
@@ -207,14 +207,14 @@
          */
         private void analyzeDeps() {
             Graph.Builder<Module> builder = new Graph.Builder<>();
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .forEach(m -> {
                     builder.addNode(m);
                     builder.addEdge(root, m);
                 });
 
-            // requires public graph
-            Graph<Module> rbg = buildGraph(requiresPublic).reduce();
+            // requires transitive graph
+            Graph<Module> rbg = buildGraph(requiresTransitive).reduce();
 
             // transitive reduction
             Graph<Module> newGraph = buildGraph(requires).reduce(builder.build().reduce());
@@ -279,7 +279,7 @@
         /**
          * Returns a graph of modules required by the specified module.
          *
-         * Requires public edges of the dependences are added to the graph.
+         * Requires transitive edges of the dependences are added to the graph.
          */
         private Graph<Module> buildGraph(Set<Module> deps) {
             Graph.Builder<Module> builder = new Graph.Builder<>();
@@ -293,7 +293,7 @@
                     builder.addEdge(root, m);
                 });
 
-            // read requires public from ModuleDescription
+            // read requires transitive from ModuleDescription
             Module source;
             while ((source = deque.poll()) != null) {
                 if (visited.contains(source))
@@ -303,7 +303,7 @@
                 builder.addNode(source);
                 Module from = source;
                 source.descriptor().requires().stream()
-                    .filter(req -> req.modifiers().contains(PUBLIC))
+                    .filter(req -> req.modifiers().contains(TRANSITIVE))
                     .map(ModuleDescriptor.Requires::name)
                     .map(configuration::findModule)
                     .flatMap(Optional::stream)
@@ -365,16 +365,16 @@
     }
 
     private boolean matches(ModuleDescriptor md, ModuleDescriptor other) {
-        // build requires public from ModuleDescriptor
-        Set<ModuleDescriptor.Requires> reqPublic = md.requires().stream()
-            .filter(req -> req.modifiers().contains(PUBLIC))
+        // build requires transitive from ModuleDescriptor
+        Set<ModuleDescriptor.Requires> reqTransitive = md.requires().stream()
+            .filter(req -> req.modifiers().contains(TRANSITIVE))
             .collect(toSet());
-        Set<ModuleDescriptor.Requires> otherReqPublic = other.requires().stream()
-            .filter(req -> req.modifiers().contains(PUBLIC))
+        Set<ModuleDescriptor.Requires> otherReqTransitive = other.requires().stream()
+            .filter(req -> req.modifiers().contains(TRANSITIVE))
             .collect(toSet());
 
-        if (!reqPublic.equals(otherReqPublic)) {
-            trace("mismatch requires public: %s%n", reqPublic);
+        if (!reqTransitive.equals(otherReqTransitive)) {
+            trace("mismatch requires transitive: %s%n", reqTransitive);
             return false;
         }
 
@@ -421,12 +421,12 @@
                 .sorted(Comparator.comparing(ModuleDescriptor::name))
                 .forEach(md -> {
                     String mn = md.name();
-                    Set<String> requiresPublic = md.requires().stream()
-                        .filter(d -> d.modifiers().contains(PUBLIC))
+                    Set<String> requiresTransitive = md.requires().stream()
+                        .filter(d -> d.modifiers().contains(TRANSITIVE))
                         .map(d -> d.name())
                         .collect(toSet());
 
-                    DotGraph.printEdges(out, graph, mn, requiresPublic);
+                    DotGraph.printEdges(out, graph, mn, requiresTransitive);
                 });
 
             out.println("}");
@@ -436,20 +436,20 @@
     /**
      * Returns a Graph of the given Configuration after transitive reduction.
      *
-     * Transitive reduction of requires public edge and requires edge have
-     * to be applied separately to prevent the requires public edges
+     * Transitive reduction of requires transitive edge and requires edge have
+     * to be applied separately to prevent the requires transitive edges
      * (e.g. U -> V) from being reduced by a path (U -> X -> Y -> V)
      * in which  V would not be re-exported from U.
      */
     private Graph<String> gengraph(Set<Module> modules) {
-        // build a Graph containing only requires public edges
+        // build a Graph containing only requires transitive edges
         // with transitive reduction.
         Graph.Builder<String> rpgbuilder = new Graph.Builder<>();
         for (Module module : modules) {
             ModuleDescriptor md = module.descriptor();
             String mn = md.name();
             md.requires().stream()
-                    .filter(d -> d.modifiers().contains(PUBLIC))
+                    .filter(d -> d.modifiers().contains(TRANSITIVE))
                     .map(d -> d.name())
                     .forEach(d -> rpgbuilder.addEdge(mn, d));
         }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Thu Sep 08 18:25:04 2016 -0700
@@ -96,7 +96,7 @@
     public boolean run() throws IOException {
         try {
             // pass 1: find API dependencies
-            Map<Archive, Set<Archive>> requiresPublic = computeRequiresPublic();
+            Map<Archive, Set<Archive>> requiresTransitive = computeRequiresTransitive();
 
             // pass 2: analyze all class dependences
             dependencyFinder.parse(automaticModules().stream());
@@ -105,13 +105,13 @@
 
             boolean missingDeps = false;
             for (Module m : automaticModules()) {
-                Set<Archive> apiDeps = requiresPublic.containsKey(m)
-                                            ? requiresPublic.get(m)
+                Set<Archive> apiDeps = requiresTransitive.containsKey(m)
+                                            ? requiresTransitive.get(m)
                                             : Collections.emptySet();
 
                 Path file = outputdir.resolve(m.name()).resolve("module-info.java");
 
-                // computes requires and requires public
+                // computes requires and requires transitive
                 Module explicitModule = toExplicitModule(m, apiDeps);
                 if (explicitModule != null) {
                     automaticToExplicitModule.put(m, explicitModule);
@@ -136,7 +136,7 @@
         return m == NOT_FOUND || m == REMOVED_JDK_INTERNALS;
     }
 
-    private Module toExplicitModule(Module module, Set<Archive> requiresPublic)
+    private Module toExplicitModule(Module module, Set<Archive> requiresTransitive)
         throws IOException
     {
         // done analysis
@@ -148,7 +148,7 @@
         }
 
         Map<String, Boolean> requires = new HashMap<>();
-        requiresPublic.stream()
+        requiresTransitive.stream()
             .map(Archive::getModule)
             .forEach(m -> requires.put(m.name(), Boolean.TRUE));
 
@@ -227,9 +227,9 @@
     }
 
     /**
-     * Compute 'requires public' dependences by analyzing API dependencies
+     * Compute 'requires transitive' dependences by analyzing API dependencies
      */
-    private Map<Archive, Set<Archive>> computeRequiresPublic() throws IOException {
+    private Map<Archive, Set<Archive>> computeRequiresTransitive() throws IOException {
         // parse the input modules
         dependencyFinder.parseExportedAPIs(automaticModules().stream());
 
--- a/src/jdk.jshell/share/classes/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/src/jdk.jshell/share/classes/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
  * Read-Eval-Print Loops (REPLs).
  */
 module jdk.jshell {
-    requires public java.compiler;
+    requires transitive java.compiler;
     requires java.desktop;
     requires java.prefs;
     requires jdk.compiler;
--- a/test/jdk/javadoc/tool/modules/Modules.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/jdk/javadoc/tool/modules/Modules.java	Thu Sep 08 18:25:04 2016 -0700
@@ -124,14 +124,14 @@
      * Module M : test module, with variable requires
      *
      * Module N :
-     *     requires public O  --->   Module O:
-     *                                 requires J   ---->   Module J:
-     *                                 exports openO          exports openJ
+     *     requires transitive O  --->   Module O:
+     *                                   requires J   ---->   Module J:
+     *                                   exports openO          exports openJ
      *
      *
      * Module L :
-     *     requires public P  --->   Module P:
-     *                                 exports openP
+     *     requires transitive P  --->   Module P:
+     *                                   exports openP
      *
      *
      */
@@ -162,14 +162,14 @@
     }
 
     @Test
-    public void testExpandRequiresPublic(Path base) throws Exception {
+    public void testExpandRequiresTransitive(Path base) throws Exception {
         Path src = base.resolve("src");
 
         createAuxiliaryModules(src);
 
         new ModuleBuilder(tb, "M")
                 .comment("The M module.")
-                .requiresPublic("N", src)
+                .requiresTransitive("N", src)
                 .requires("L", src)
                 .exports("p")
                 .classes("package p; public class Main { openO.O o; openN.N n; openL.L l; }")
@@ -193,7 +193,7 @@
 
         new ModuleBuilder(tb, "M")
                 .comment("The M module.")
-                .requiresPublic("N", src)
+                .requiresTransitive("N", src)
                 .requires("L", src)
                 .requires("O", src)
                 .exports("p")
@@ -221,7 +221,7 @@
 
         new ModuleBuilder(tb, "M")
                 .comment("The M module.")
-                .requiresPublic("N", src)
+                .requiresTransitive("N", src)
                 .requires("L", src)
                 .requires("O", src)
                 .exports("p")
@@ -243,7 +243,7 @@
 
         new ModuleBuilder(tb, "M")
                 .comment("The M module.")
-                .requiresPublic("N", src)
+                .requiresTransitive("N", src)
                 .requires("L", src)
                 .requires("O", src)
                 .exports("p")
@@ -269,7 +269,7 @@
         new ModuleBuilder(tb, "L")
                 .comment("The L module.")
                 .exports("openL")
-                .requiresPublic("P")
+                .requiresTransitive("P")
                 .classes("package openL; /** Klass L open */ public class L { }")
                 .classes("package closedL;  /** Klass L closed */ public class L { }")
                 .write(src);
@@ -277,7 +277,7 @@
         new ModuleBuilder(tb, "N")
                 .comment("The N module.")
                 .exports("openN")
-                .requiresPublic("O")
+                .requiresTransitive("O")
                 .classes("package openN; /** Klass N open */ public class N  { }")
                 .classes("package closedN; /** Klass N closed */ public class N { }")
                 .write(src);
--- a/test/jdk/jshell/CompletionSuggestionTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/jdk/jshell/CompletionSuggestionTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,6 +28,7 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.jdeps/com.sun.tools.javap
+ *          jdk.jshell/jdk.jshell:private
  * @library /tools/lib
  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
  * @build KullaTesting TestingInputStream Compiler
--- a/test/jdk/jshell/ComputeFQNsTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/jdk/jshell/ComputeFQNsTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,6 +28,7 @@
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jshell/jdk.jshell:private
  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
  * @build KullaTesting TestingInputStream Compiler
  * @run testng ComputeFQNsTest
--- a/test/jdk/jshell/HistoryTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/jdk/jshell/HistoryTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @summary Test Completion
  * @modules jdk.internal.le/jdk.internal.jline.extra
- *          jdk.jshell/jdk.internal.jshell.tool
+ *          jdk.jshell/jdk.internal.jshell.tool:private
  * @build HistoryTest
  * @run testng HistoryTest
  */
--- a/test/lib/annotations/annotations/classfile/ClassfileInspector.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/lib/annotations/annotations/classfile/ClassfileInspector.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1188,7 +1188,7 @@
         }
 
         @Override
-        public Void visitConcealedPackages(ConcealedPackages_attribute attr, T p) {
+        public Void visitPackages(Packages_attribute attr, T p) {
             return null;
         }
 
--- a/test/tools/javac/6304921/TestLog.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/6304921/TestLog.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,7 +28,7 @@
  * @modules jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.parser
  *          jdk.compiler/com.sun.tools.javac.tree
- *          jdk.compiler/com.sun.tools.javac.util
+ *          jdk.compiler/com.sun.tools.javac.util:private
  */
 import java.lang.reflect.Field;
 import java.io.InputStream;
--- a/test/tools/javac/6410653/T6410653.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/6410653/T6410653.java	Thu Sep 08 18:25:04 2016 -0700
@@ -27,7 +27,7 @@
  * @summary REGRESSION: javac crashes if -d or -s argument is a file
  * @author  Peter von der Ah\u00e9
  * @modules java.compiler
- *          jdk.compiler/com.sun.tools.javac.util
+ *          jdk.compiler/com.sun.tools.javac.util:private
  */
 
 import java.lang.reflect.Field;
--- a/test/tools/javac/MethodParameters/AttributeVisitor.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/MethodParameters/AttributeVisitor.java	Thu Sep 08 18:25:04 2016 -0700
@@ -34,7 +34,6 @@
     public R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p) { return null; }
     public R visitCode(Code_attribute attr, P p) { return null; }
     public R visitCompilationID(CompilationID_attribute attr, P p) { return null; }
-    public R visitConcealedPackages(ConcealedPackages_attribute attr, P p) { return null; }
     public R visitConstantValue(ConstantValue_attribute attr, P p) { return null; }
     public R visitDeprecated(Deprecated_attribute attr, P p) { return null; }
     public R visitEnclosingMethod(EnclosingMethod_attribute attr, P p) { return null; }
@@ -47,6 +46,7 @@
     public R visitMainClass(MainClass_attribute attr, P p) { return null; }
     public R visitMethodParameters(MethodParameters_attribute attr, P p) { return null; }
     public R visitModule(Module_attribute attr, P p) { return null; }
+    public R visitPackages(Packages_attribute attr, P p) { return null; }
     public R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p) { return null; }
     public R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p) { return null; }
     public R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p) { return null; }
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -63,23 +63,13 @@
     }
 
     @Test
-    public void testDynamicExports(Path base) throws Exception {
-        ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .exports("pack", ExportFlag.DYNAMIC)
-                .write(base);
-        tb.writeJavaFiles(base, "package pack; public class C extends java.util.ArrayList{ }");
-        compile(base);
-        testModuleAttribute(base, moduleDescriptor);
-    }
-
-    @Test
     public void testSeveralExports(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exports("pack")
                 .exports("pack2")
-                .exports("pack3", ExportFlag.DYNAMIC)
+                .exports("pack3")
                 .exports("pack4")
-                .exports("pack5", ExportFlag.DYNAMIC)
+                .exports("pack5")
                 .write(base);
         tb.writeJavaFiles(base,
                 "package pack; public class A { }",
@@ -104,7 +94,7 @@
     @Test
     public void testQualifiedDynamicExports(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .exportsTo("pack", "jdk.compiler", ExportFlag.DYNAMIC)
+                .exportsTo("pack", "jdk.compiler")
                 .write(base);
         tb.writeJavaFiles(base, "package pack; public class A { }");
         compile(base);
@@ -117,8 +107,8 @@
                 .exportsTo("pack", "jdk.compiler, jdk.jdeps")
                 .exportsTo("pack2", "jdk.jdeps")
                 .exportsTo("pack3", "jdk.compiler")
-                .exportsTo("pack4", "jdk.compiler, jdk.jdeps", ExportFlag.DYNAMIC)
-                .exportsTo("pack5", "jdk.compiler", ExportFlag.DYNAMIC)
+                .exportsTo("pack4", "jdk.compiler, jdk.jdeps")
+                .exportsTo("pack5", "jdk.compiler")
                 .write(base);
         tb.writeJavaFiles(base,
                 "package pack; public class A {}",
@@ -140,9 +130,9 @@
     }
 
     @Test
-    public void testRequiresPublic(Path base) throws Exception {
+    public void testRequiresTransitive(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .requires("jdk.jdeps", RequiresFlag.PUBLIC)
+                .requires("jdk.jdeps", RequiresFlag.TRANSITIVE)
                 .write(base);
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
@@ -160,12 +150,12 @@
     @Test
     public void testSeveralRequires(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .requires("jdk.jdeps", RequiresFlag.PUBLIC)
+                .requires("jdk.jdeps", RequiresFlag.TRANSITIVE)
                 .requires("jdk.compiler")
                 .requires("m2", RequiresFlag.STATIC)
                 .requires("m3")
-                .requires("m4", RequiresFlag.PUBLIC)
-                .requires("m5", RequiresFlag.STATIC, RequiresFlag.PUBLIC)
+                .requires("m4", RequiresFlag.TRANSITIVE)
+                .requires("m5", RequiresFlag.STATIC, RequiresFlag.TRANSITIVE)
                 .write(base.resolve("m1"));
         tb.writeJavaFiles(base.resolve("m2"), "module m2 { }");
         tb.writeJavaFiles(base.resolve("m3"), "module m3 { }");
@@ -226,24 +216,24 @@
         Path m1 = base.resolve("m1");
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exports("pack1")
-                .exports("pack3", ExportFlag.DYNAMIC)
+                .exports("pack3")
                 .exportsTo("packTo1", "m2")
-                .exportsTo("packTo3", "m3", ExportFlag.DYNAMIC)
+                .exportsTo("packTo3", "m3")
                 .requires("jdk.compiler")
-                .requires("m2", RequiresFlag.PUBLIC)
+                .requires("m2", RequiresFlag.TRANSITIVE)
                 .requires("m3", RequiresFlag.STATIC)
-                .requires("m4", RequiresFlag.PUBLIC, RequiresFlag.STATIC)
+                .requires("m4", RequiresFlag.TRANSITIVE, RequiresFlag.STATIC)
                 .provides("java.util.List", "pack1.C")
                 .uses("java.util.List")
                 .uses("java.nio.file.Path")
                 .provides("java.util.List", "pack2.D")
-                .requires("jdk.jdeps", RequiresFlag.STATIC, RequiresFlag.PUBLIC)
+                .requires("jdk.jdeps", RequiresFlag.STATIC, RequiresFlag.TRANSITIVE)
                 .requires("m5", RequiresFlag.STATIC)
-                .requires("m6", RequiresFlag.PUBLIC)
+                .requires("m6", RequiresFlag.TRANSITIVE)
                 .requires("java.compiler")
-                .exportsTo("packTo4", "java.compiler", ExportFlag.DYNAMIC)
+                .exportsTo("packTo4", "java.compiler")
                 .exportsTo("packTo2", "java.compiler")
-                .exports("pack4", ExportFlag.DYNAMIC)
+                .exports("pack4")
                 .exports("pack2")
                 .write(m1);
         tb.writeJavaFiles(m1, "package pack1; public class C extends java.util.ArrayList{ }",
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Thu Sep 08 18:25:04 2016 -0700
@@ -152,7 +152,7 @@
     }
 
     enum RequiresFlag implements Mask {
-        PUBLIC("public", Module_attribute.ACC_TRANSITIVE),
+        TRANSITIVE("transitive", Module_attribute.ACC_TRANSITIVE),
         STATIC("static", Module_attribute.ACC_STATIC_PHASE);
 
         private final String token;
@@ -170,7 +170,7 @@
     }
 
     enum ExportFlag implements Mask {
-        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE);
+        PRIVATE("private", Module_attribute.ACC_REFLECTION);
 
         private final String token;
         private final int mask;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ConflictingExports/exported/Class.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package exported;
+
+public class Class {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ConflictingExports/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.conflicting.exports
+
+module ConflictingExports {
+     exports exported;
+     exports exported;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ConflictingExportsToModule/exported/Class.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package exported;
+
+public class Class {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ConflictingExportsToModule/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.conflicting.exports.to.module
+
+module ConflictingExports {
+     exports exported to java.base;
+     exports private exported to java.base;
+}
--- a/test/tools/javac/diags/examples/DuplicateExports/exported/Class.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package exported;
-
-public class Class {
-}
--- a/test/tools/javac/diags/examples/DuplicateExports/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.duplicate.exports
-
-module DuplicateExports {
-     exports exported;
-     exports exported;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ExpectedModule.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.expected.module
+
+weak class ExpectedModule { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoExportsInWeak/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.no.exports.in.weak
+
+weak module NoExportsInWeak {
+    exports p;
+}
--- a/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package exported;
-
-public interface Service {
-}
--- a/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/impl/ServiceImplementation.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package impl;
-
-import exported.Service;
-
-public class ServiceImplementation implements Service {
-    ServiceImplementation() {
-    }
-}
--- a/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.service.implementation.no.args.constructor.not.public
-
-module ServiceImplementationNoArgsConstructorNotPublic {
-     exports exported;
-     provides exported.Service with impl.ServiceImplementation;
-}
--- a/test/tools/javac/modules/AutomaticModules.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/AutomaticModules.java	Thu Sep 08 18:25:04 2016 -0700
@@ -193,7 +193,7 @@
         Files.createDirectories(depClasses);
 
         tb.writeJavaFiles(depSrc,
-                          "module m1 { requires public automatic; }",
+                          "module m1 { requires transitive automatic; }",
                           "package dep; public class Dep { api.Api api; }");
 
         new JavacTask(tb)
@@ -308,4 +308,54 @@
             throw new Exception("expected output not found: " + log);
         }
     }
+
+    @Test
+    public void testDropTrailingVersion(Path base) throws Exception {
+        Path legacySrc = base.resolve("legacy-src");
+        tb.writeJavaFiles(legacySrc,
+                          "package api; public class Api {}");
+        Path legacyClasses = base.resolve("legacy-classes");
+        Files.createDirectories(legacyClasses);
+
+        String log = new JavacTask(tb)
+                .options()
+                .outdir(legacyClasses)
+                .files(findJavaFiles(legacySrc))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.isEmpty()) {
+            throw new Exception("unexpected output: " + log);
+        }
+
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        Path jar = modulePath.resolve("test1.jar");
+
+        new JarTask(tb, jar)
+          .baseDir(legacyClasses)
+          .files("api/Api.class")
+          .run();
+
+        Path moduleSrc = base.resolve("module-src");
+        Path m = moduleSrc.resolve("m");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        tb.writeJavaFiles(m,
+                          "module m { requires test; }",
+                          "package impl; public class Impl { public void e(api.Api api) { } }");
+
+        new JavacTask(tb)
+                .options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString())
+                .outdir(classes)
+                .files(findJavaFiles(moduleSrc))
+                .run()
+                .writeAll();
+    }
 }
--- a/test/tools/javac/modules/EdgeCases.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/EdgeCases.java	Thu Sep 08 18:25:04 2016 -0700
@@ -202,7 +202,7 @@
 
         Files.createDirectories(modulePath);
 
-        Path automaticJar = modulePath.resolve("m1-1.0.jar");
+        Path automaticJar = modulePath.resolve("a-1.0.jar");
 
         new JarTask(tb, automaticJar)
           .baseDir(automaticClasses)
@@ -212,11 +212,11 @@
         Path src = base.resolve("src");
         Path src_m2 = src.resolve("m2");
         tb.writeJavaFiles(src_m2,
-                          "module m2 { requires m1; exports api2; }",
+                          "module m2 { requires a; exports api2; }",
                           "package api2; public class Api2 { public static api1.Api1 get() { return null; } }");
         Path src_m3 = src.resolve("m3");
         tb.writeJavaFiles(src_m3,
-                          "module m3 { requires m1; requires m2; }",
+                          "module m3 { requires a; requires m2; }",
                           "package test; public class Test { { api2.Api2.get(); api1.Api1 a1; } }");
         Path classes = base.resolve("classes");
         tb.createDirectories(classes);
--- a/test/tools/javac/modules/GraphsTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/GraphsTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -55,19 +55,19 @@
 
     /**
      * Tests diamond graph with an automatic module added in.
-     * +-------------+          +--------------------+         +------------------+
-     * | module M    |          | module N           |         | module O         |
-     * |             | ----->   |                    | --->    |                  |  --> J.jar
-     * | require N   |          | requires public  O |         |                  |
-     * | require L   |          |                    |         +------------------+
-     * +-------------+          +--------------------+                  ^
+     * +-------------+          +-----------------------+         +------------------+
+     * | module M    |          | module N              |         | module O         |
+     * |             | ----->   |                       | --->    |                  |  --> J.jar
+     * | require N   |          | requires transitive O |         |                  |
+     * | require L   |          |                       |         +------------------+
+     * +-------------+          +-----------------------+                  ^
      *       |                                                          |
-     *       |                  +--------------------+                  |
-     *       ------------------>| module L           |                  |
-     *                          |                    |------------------
-     *                          | requires public O  |
-     *                          |                    |
-     *                          +--------------------+
+     *       |                  +-----------------------+                  |
+     *       ------------------>| module L              |                  |
+     *                          |                       |------------------
+     *                          | requires transitive O |
+     *                          |                       |
+     *                          +-----------------------+
      *
      */
     @Test
@@ -92,18 +92,18 @@
 
         new ModuleBuilder(tb, "O")
                 .exports("openO")
-                .requiresPublic("J", jarModules)
+                .requiresTransitive("J", jarModules)
                 .classes("package openO; public class O { openJ.J j; }")
                 .classes("package closedO; public class O { }")
                 .build(modSrc, modules);
         new ModuleBuilder(tb, "N")
-                .requiresPublic("O", modules, jarModules)
+                .requiresTransitive("O", modules, jarModules)
                 .exports("openN")
                 .classes("package openN; public class N { }")
                 .classes("package closedN; public class N { }")
                 .build(modSrc, modules);
         new ModuleBuilder(tb, "L")
-                .requiresPublic("O", modules, jarModules)
+                .requiresTransitive("O", modules, jarModules)
                 .exports("openL")
                 .classes("package openL; public class L { }")
                 .classes("package closedL; public class L { }")
@@ -171,18 +171,18 @@
     /**
      * Tests graph where module M reexport package of N, but N export the package only to M.
      *
-    +-------------+        +--------------------+        +---------------+
-    | module L    |        | module M           |        | module N      |
-    |             | -----> |                    | -----> |               |
-    |  requires M |        |  requires public N |        | exports P to M|
-    +-------------+        |                    |        +---------------+
-                           +--------------------+
+    +-------------+        +------------------------+        +---------------+
+    | module L    |        | module M               |        | module N      |
+    |             | -----> |                        | -----> |               |
+    |  requires M |        |  requires transitive N |        | exports P to M|
+    +-------------+        |                        |        +---------------+
+                           +------------------------+
     */
     @Test
     public void reexportOfQualifiedExport(Path base) throws Exception {
         Path modSrc = base.resolve("modSrc");
         new ModuleBuilder(tb, "M")
-                .requiresPublic("N")
+                .requiresTransitive("N")
                 .write(modSrc);
         new ModuleBuilder(tb, "N")
                 .exportsTo("pack", "M")
--- a/test/tools/javac/modules/ModuleInfoTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/ModuleInfoTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -34,6 +34,7 @@
  * @run main ModuleInfoTest
  */
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
@@ -154,31 +155,6 @@
     }
 
     /**
-     * Verify that dynamic exports are reported as missing.
-     */
-    @Test
-    public void testExportsDynamicNotFound(Path base) throws Exception {
-        Path src = base.resolve("src");
-
-        tb.writeJavaFiles(src.resolve("m1"), "module m1 { requires m2; }", "package pack1; public class B { pack.A a; }");
-        tb.writeJavaFiles(src.resolve("m2"), "module m2 { exports dynamic pack; }","package pack; public class A { }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("B.java:1:37: compiler.err.not.def.access.package.cant.access: pack.A, pack"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
      * Verify that a simple loop is detected.
      */
     @Test
@@ -228,12 +204,12 @@
      * Verify that a multi-module loop is detected.
      */
     @Test
-    public void testRequiresPublicLoop(Path base) throws Exception {
+    public void testRequiresTransitiveLoop(Path base) throws Exception {
         Path src = base.resolve("src");
         Path src_m1 = src.resolve("m1");
         tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { requires m2; }");
         Path src_m2 = src.resolve("m2");
-        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires public m3; }");
+        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires transitive m3; }");
         Path src_m3 = src.resolve("m3");
         tb.writeFile(src_m3.resolve("module-info.java"), "module m3 { requires m1; }");
 
@@ -248,7 +224,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("module-info.java:1:29: compiler.err.cyclic.requires: m3"))
+        if (!log.contains("module-info.java:1:33: compiler.err.cyclic.requires: m3"))
             throw new Exception("expected output not found");
     }
 
@@ -282,12 +258,12 @@
      * Verify that duplicate requires are detected.
      */
     @Test
-    public void testDuplicateRequiresPublicStatic(Path base) throws Exception {
+    public void testDuplicateRequiresTransitiveStatic(Path base) throws Exception {
         Path src = base.resolve("src");
         Path src_m1 = src.resolve("m1");
         tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
         Path src_m2 = src.resolve("m2");
-        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires public m1; requires static m1; }");
+        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { requires transitive m1; requires static m1; }");
 
         Path classes = base.resolve("classes");
         Files.createDirectories(classes);
@@ -300,109 +276,115 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("module-info.java:1:49: compiler.err.duplicate.requires: m1"))
+        if (!log.contains("module-info.java:1:53: compiler.err.duplicate.requires: m1"))
             throw new Exception("expected output not found");
     }
 
     /**
+     * Verify that duplicate exported packages are detected correctly.
+     */
+    @Test
+    public void testConflictingExports_packages(Path base) throws Exception {
+        verifyConflictingExports_packages(base,
+                                          "exports p; exports q;",
+                                          null);
+        verifyConflictingExports_packages(base,
+                                          "exports p; exports p;",
+                                          "module-info.java:1:32: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p; exports private p;",
+                                          "module-info.java:1:40: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p; exports p to m2;",
+                                          "module-info.java:1:32: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p; exports private p to m2;",
+                                          null);
+        verifyConflictingExports_packages(base,
+                                          "exports private p; exports p;",
+                                          "module-info.java:1:40: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p; exports private p;",
+                                          "module-info.java:1:48: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p; exports p to m2;",
+                                          "module-info.java:1:40: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p; exports private p to m2;",
+                                          "module-info.java:1:48: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports p;",
+                                          "module-info.java:1:38: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports private p;",
+                                          "module-info.java:1:46: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports p to m2;",
+                                          "module-info.java:1:43: compiler.err.conflicting.exports.to.module: m2");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports private p to m2;",
+                                          "module-info.java:1:51: compiler.err.conflicting.exports.to.module: m2");
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports p;",
+                                          null);
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports private p;",
+                                          "module-info.java:1:54: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports p to m2;",
+                                          "module-info.java:1:51: compiler.err.conflicting.exports.to.module: m2");
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports private p to m2;",
+                                          "module-info.java:1:54: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports p to m3;",
+                                          "module-info.java:1:38: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports p to m2; exports private p to m3;",
+                                          "module-info.java:1:46: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports p to m3;",
+                                          "module-info.java:1:46: compiler.err.conflicting.exports: p");
+        verifyConflictingExports_packages(base,
+                                          "exports private p to m2; exports private p to m3;",
+                                          "module-info.java:1:54: compiler.err.conflicting.exports: p");
+    }
+
+    private void verifyConflictingExports_packages(Path base, String code, String expected) throws Exception {
+        Files.createDirectories(base);
+        tb.cleanDirectory(base);
+
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src.resolve("m1"),
+                          "module m1 { " + code + " }",
+                          "package p; public class P {}",
+                          "package q; public class Q {}");
+        tb.writeJavaFiles(src.resolve("m2"),
+                          "module m2 { requires m1; }");
+        tb.writeJavaFiles(src.resolve("m3"),
+                          "module m3 { requires m1; }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(expected != null ? Task.Expect.FAIL : Task.Expect.SUCCESS)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (expected != null && !log.contains(expected))
+            throw new Exception("expected output not found, actual output: " + log);
+    }
+
+    /**
      * Verify that duplicate exported packages are detected.
      */
     @Test
-    public void testDuplicateExports_packages(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src, "module m1 { exports p; exports p; }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics")
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("module-info.java:1:32: compiler.err.duplicate.exports: p"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
-     * Verify that duplicate exported packages are detected.
-     */
-    @Test
-    public void testDuplicateDynamicExports_packages(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src, "module m1 { exports p; exports dynamic p; }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics")
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("module-info.java:1:40: compiler.err.duplicate.exports: p"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
-     * Verify that duplicate exported packages are detected.
-     */
-    @Test
-    public void testDuplicateExports_packages2(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports p to m2; }");
-        tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("module-info.java:1:32: compiler.err.duplicate.exports: p"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
-     * Verify that duplicate exported packages are detected.
-     */
-    @Test
-    public void testDuplicateDynamicExports_packages2(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports dynamic p to m2; }");
-        tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("module-info.java:1:40: compiler.err.duplicate.exports: p"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
-     * Verify that duplicate exported packages are detected.
-     */
-    @Test
-    public void testDuplicateExports_modules(Path base) throws Exception {
+    public void testConflictingExports_modules(Path base) throws Exception {
         Path src = base.resolve("src");
         Path src_m1 = src.resolve("m1");
         tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
@@ -420,33 +402,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("module-info.java:1:30: compiler.err.duplicate.exports: m1"))
-            throw new Exception("expected output not found");
-    }
-
-    /**
-     * Verify that duplicate exported packages are detected.
-     */
-    @Test
-    public void testDuplicateDynamicExports_modules(Path base) throws Exception {
-        Path src = base.resolve("src");
-        Path src_m1 = src.resolve("m1");
-        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
-        Path src_m2 = src.resolve("m2");
-        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { exports dynamic p to m1, m1; }");
-
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("module-info.java:1:38: compiler.err.duplicate.exports: m1"))
+        if (!log.contains("module-info.java:1:30: compiler.err.conflicting.exports.to.module: m1"))
             throw new Exception("expected output not found");
     }
 
@@ -487,8 +443,12 @@
                     .writeAll()
                     .getOutput(Task.OutputKind.DIRECT);
 
-            if (!log.matches("(?s)^module\\-info\\.java:\\d+:\\d+: compiler\\.err\\.expected: token\\.identifier.*"))
-                throw new Exception("expected output not found");
+            String expect_prefix = "(?s)^module\\-info\\.java:\\d+:\\d+: ";
+            String expect_message = "compiler\\.err\\.expected: token\\.identifier";
+            String expect_suffix = ".*";
+            String expect = expect_prefix + expect_message + expect_suffix;
+            if (!log.matches(expect))
+                throw new Exception("expected output not found for: " + moduleInfo + "; actual: " + log);
         }
     }
 }
--- a/test/tools/javac/modules/ModulePathTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/ModulePathTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -177,7 +177,7 @@
                 .run()
                 .writeAll();
 
-        Path moduleJar = base.resolve("m1.jar");
+        Path moduleJar = base.resolve("a.jar");
         new JarTask(tb, moduleJar)
           .baseDir(jarClasses)
           .files("p/CC.class")
@@ -190,7 +190,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
-                .options("--module-path", moduleJar.toString(), "--add-modules", "m1")
+                .options("--module-path", moduleJar.toString(), "--add-modules", "a")
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
--- a/test/tools/javac/modules/PackageConflictTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/PackageConflictTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -124,31 +124,6 @@
     }
 
     @Test
-    public void testConflictInDependenciesDynamicExport(Path base) throws Exception {
-        Path m1 = base.resolve("m1");
-        Path m2 = base.resolve("m2");
-        Path m3 = base.resolve("m3");
-        tb.writeJavaFiles(m1,
-                "module m1 { exports test; }",
-                "package test; public class A { }");
-        tb.writeJavaFiles(m2,
-                "module m2 { exports dynamic test; }",
-                "package test; public class B { }");
-        tb.writeJavaFiles(m3,
-                "module m3 { requires m1; requires m2; }",
-                "package impl; public class Impl { }");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        new JavacTask(tb)
-                .options("-XDrawDiagnostics", "--module-source-path", base.toString())
-                .outdir(classes)
-                .files(findJavaFiles(base))
-                .run(Task.Expect.SUCCESS)
-                .writeAll();
-    }
-
-    @Test
     public void testSimple2(Path base) throws Exception {
         Path modSrc = base.resolve("modSrc");
         Path modules = base.resolve("modules");
--- a/test/tools/javac/modules/PatchModulesTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/PatchModulesTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -28,7 +28,7 @@
  * @library /tools/lib
  * @modules
  *      jdk.compiler/com.sun.tools.javac.api
- *      jdk.compiler/com.sun.tools.javac.file
+ *      jdk.compiler/com.sun.tools.javac.file:private
  *      jdk.compiler/com.sun.tools.javac.main
  * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
  * @run main PatchModulesTest
--- a/test/tools/javac/modules/ProvidesTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/ProvidesTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -309,19 +309,11 @@
                 "package p1; public class C1 { }",
                 "package p2; class C2 extends p1.C1 { }");
 
-        List<String> output = new JavacTask(tb)
-                .options("-XDrawDiagnostics")
+        new JavacTask(tb)
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        List<String> expected = Arrays.asList("module-info.java:1:34: compiler.err.not.def.public.cant.access: p2.C2, p2",
-                "1 error");
-        if (!output.containsAll(expected)) {
-            throw new Exception("Expected output not found");
-        }
+                .run()
+                .writeAll();
     }
 
     @Test
@@ -355,19 +347,11 @@
                 "package p1; public class C1 { }",
                 "package p2; public class C2 extends p1.C1 { private C2() { } }");
 
-        List<String> output = new JavacTask(tb)
-                .options("-XDrawDiagnostics")
+        new JavacTask(tb)
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        List<String> expected = Arrays.asList(
-                "module-info.java:1:46: compiler.err.service.implementation.no.args.constructor.not.public: p2.C2");
-        if (!output.containsAll(expected)) {
-            throw new Exception("Expected output not found");
-        }
+                .run()
+                .writeAll();
     }
 
     @Test
--- a/test/tools/javac/modules/ReportNonExistentPackageTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/ReportNonExistentPackageTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -64,24 +64,6 @@
     }
 
     @Test
-    public void testExportDynamicUnknownPackage(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src, "module m { exports dynamic p1; }");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics")
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-        if (!log.contains("module-info.java:1:28: compiler.err.package.empty.or.not.found: p1"))
-            throw new Exception("expected output not found");
-    }
-
-    @Test
     public void testExportEmptyPackage(Path base) throws Exception {
         Path src = base.resolve("src");
         tb.writeJavaFiles(src,
@@ -121,4 +103,45 @@
         if (!log.contains("module-info.java:1:20: compiler.err.package.empty.or.not.found: p1"))
             throw new Exception("expected output not found");
     }
+
+    @Test
+    public void testExportPrivateEmptyPackage(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "module m { exports private p; }");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("module-info.java:1:28: compiler.err.package.empty.or.not.found: p"))
+            throw new Exception("expected output not found, actual output: " + log);
+    }
+
+    @Test
+    public void testExportPrivateOnlyWithResources(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "module m { exports private p; }");
+        Path resource = src.resolve("p").resolve("resource.properties");
+        Files.createDirectories(resource.getParent());
+        Files.newOutputStream(resource).close();
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .sourcepath(src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.equals(""))
+            throw new Exception("expected output not found, actual output: " + log);
+    }
 }
--- a/test/tools/javac/modules/RequiresPublicTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary tests for "requires public"
- * @library /tools/lib
- * @modules
- *      jdk.compiler/com.sun.tools.javac.api
- *      jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
- * @run main RequiresPublicTest
- */
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import toolbox.JavacTask;
-import toolbox.Task;
-import toolbox.ToolBox;
-
-public class RequiresPublicTest extends ModuleTestBase {
-
-    public static void main(String... args) throws Exception {
-        RequiresPublicTest t = new RequiresPublicTest();
-        t.runTests();
-    }
-
-    @Test
-    public void testJavaSE_OK(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src,
-                "module m { requires java.se; }",
-                "import java.awt.Frame;\n"  // in java.se
-                + "class Test {\n"
-                + "    Frame f;\n"
-                + "}");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        new JavacTask(tb, Task.Mode.CMDLINE)
-                .files(findJavaFiles(src))
-                .outdir(classes)
-                .run()
-                .writeAll();
-    }
-
-    @Test
-    public void testJavaSE_Fail(Path base) throws Exception {
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src,
-                "module m { requires java.se; }",
-                "import com.sun.source.tree.Tree;\n" // not in java.se (in jdk.compiler)
-                + "class Test {\n"
-                + "    Tree t;\n"
-                + "}");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-XDrawDiagnostics")
-                .files(findJavaFiles(src))
-                .outdir(classes)
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree"))
-            throw new Exception("expected output not found");
-    }
-
-    @Test
-    public void testComplex_OK(Path base) throws Exception {
-        Path src = getComplexSrc(base, "", "");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("--module-source-path", src.toString())
-                .files(findJavaFiles(src))
-                .outdir(classes)
-                .run()
-                .writeAll();
-    }
-
-    @Test
-    public void testComplex_Fail(Path base) throws Exception {
-        Path src = getComplexSrc(base,
-                "import p5.C5; import p6.C6; import p7.C7;\n",
-                "C5 c5; C6 c6; C7 c7;\n");
-        Path classes = base.resolve("classes");
-        Files.createDirectories(classes);
-
-        String log = new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-XDrawDiagnostics",
-                        "--module-source-path", src.toString())
-                .files(findJavaFiles(src))
-                .outdir(classes)
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        String[] expect = {
-            "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5",
-            "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6",
-            "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7",
-            "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)"
-        };
-
-        for (String e: expect) {
-            if (!log.contains(e))
-                throw new Exception("expected output not found: " + e);
-        }
-    }
-
-    /*
-     * Set up the following module graph
-     *     m1 -> m2 => m3 => m4 -> m5
-     *              -> m6 => m7
-     * where -> is requires, => is requires public
-     */
-    Path getComplexSrc(Path base, String m1_extraImports, String m1_extraUses) throws Exception {
-        Path src = base.resolve("src");
-
-        Path src_m1 = src.resolve("m1");
-        tb.writeJavaFiles(src_m1,
-                "module m1 { requires m2; }",
-                "package p1;\n"
-                + "import p2.C2;\n"
-                + "import p3.C3;\n"
-                + "import p4.C4;\n"
-                + m1_extraImports
-                + "class C1 {\n"
-                + "  C2 c2; C3 c3; C4 c4;\n"
-                + m1_extraUses
-                + "}\n");
-
-        Path src_m2 = src.resolve("m2");
-        tb.writeJavaFiles(src_m2,
-                "module m2 {\n"
-                + "  requires public m3;\n"
-                + "  requires        m6;\n"
-                + "  exports p2;\n"
-                + "}",
-                "package p2;\n"
-                + "public class C2 { }\n");
-
-        Path src_m3 = src.resolve("m3");
-        tb.writeJavaFiles(src_m3,
-                "module m3 { requires public m4; exports p3; }",
-                "package p3;\n"
-                + "public class C3 { }\n");
-
-        Path src_m4 = src.resolve("m4");
-        tb.writeJavaFiles(src_m4,
-                "module m4 { requires m5; exports p4; }",
-                "package p4;\n"
-                + "public class C4 { }\n");
-
-        Path src_m5 = src.resolve("m5");
-        tb.writeJavaFiles(src_m5,
-                "module m5 { exports p5; }",
-                "package p5;\n"
-                + "public class C5 { }\n");
-
-        Path src_m6 = src.resolve("m6");
-        tb.writeJavaFiles(src_m6,
-                "module m6 { requires public m7; exports p6; }",
-                "package p6;\n"
-                + "public class C6 { }\n");
-
-        Path src_m7 = src.resolve("m7");
-        tb.writeJavaFiles(src_m7,
-                "module m7 { exports p7; }",
-                "package p7;\n"
-                + "public class C7 { }\n");
-
-        return src;
-    }
-}
--- a/test/tools/javac/modules/RequiresStaticTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/modules/RequiresStaticTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -151,7 +151,7 @@
      *              \       /
      *                v   v
      *                  m6 => m7 --> m8
-     * where -> is requires, => is requires public, --> is requires static, -=-> is requires public static
+     * where -> is requires, => is requires transitive, --> is requires static, -=-> is requires transitive static
      */
     Path getComplexSrc(Path base, String m1_extraImports, String m1_extraUses) throws Exception {
         Path src = base.resolve("src");
@@ -172,7 +172,7 @@
         Path src_m2 = src.resolve("m2");
         tb.writeJavaFiles(src_m2,
                 "module m2 {\n"
-                + "  requires public m3;\n"
+                + "  requires transitive m3;\n"
                 + "  requires static m6;\n"
                 + "  exports p2;\n"
                 + "}",
@@ -181,7 +181,7 @@
 
         Path src_m3 = src.resolve("m3");
         tb.writeJavaFiles(src_m3,
-                "module m3 { requires public static m4; exports p3; }",
+                "module m3 { requires transitive static m4; exports p3; }",
                 "package p3;\n"
                 + "public class C3 { }\n");
 
@@ -199,7 +199,7 @@
 
         Path src_m6 = src.resolve("m6");
         tb.writeJavaFiles(src_m6,
-                "module m6 { requires public m7; exports p6; }",
+                "module m6 { requires transitive m7; exports p6; }",
                 "package p6;\n"
                 + "public class C6 { p7.C7 c7; }\n");
 
@@ -280,7 +280,7 @@
     }
 
     @Test
-    public void testRequiresPublicStatic(Path base) throws Exception {
+    public void testRequiresTransitiveStatic(Path base) throws Exception {
         Path src = base.resolve("src");
         Path m1 = src.resolve("m1");
         tb.writeJavaFiles(m1,
@@ -300,7 +300,7 @@
 
         Path m2 = src.resolve("m2");
         tb.writeJavaFiles(m2,
-                "module m2 { requires public static m1; }");
+                "module m2 { requires transitive static m1; }");
 
         Path m2Classes = classes.resolve("m2");
         Files.createDirectories(m2Classes);
@@ -356,7 +356,7 @@
     }
 
     @Test
-    public void testRequiresStaticPublic(Path base) throws Exception {
+    public void testRequiresStaticTransitive(Path base) throws Exception {
         Path src = base.resolve("src");
         Path m1 = src.resolve("m1");
         tb.writeJavaFiles(m1,
@@ -376,7 +376,7 @@
 
         Path m2 = src.resolve("m2");
         tb.writeJavaFiles(m2,
-                "module m2 { requires public static m1; }");
+                "module m2 { requires transitive static m1; }");
 
         Path m2Classes = classes.resolve("m2");
         Files.createDirectories(m2Classes);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/modules/RequiresTransitiveTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary tests for "requires transitive"
+ * @library /tools/lib
+ * @modules
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @run main RequiresTransitiveTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class RequiresTransitiveTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        RequiresTransitiveTest t = new RequiresTransitiveTest();
+        t.runTests();
+    }
+
+    @Test
+    public void testJavaSE_OK(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "module m { requires java.se; }",
+                "import java.awt.Frame;\n"  // in java.se
+                + "class Test {\n"
+                + "    Frame f;\n"
+                + "}");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .files(findJavaFiles(src))
+                .outdir(classes)
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testJavaSE_Fail(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "module m { requires java.se; }",
+                "import com.sun.source.tree.Tree;\n" // not in java.se (in jdk.compiler)
+                + "class Test {\n"
+                + "    Tree t;\n"
+                + "}");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics")
+                .files(findJavaFiles(src))
+                .outdir(classes)
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testComplex_OK(Path base) throws Exception {
+        Path src = getComplexSrc(base, "", "");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .outdir(classes)
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testComplex_Fail(Path base) throws Exception {
+        Path src = getComplexSrc(base,
+                "import p5.C5; import p6.C6; import p7.C7;\n",
+                "C5 c5; C6 c6; C7 c7;\n");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .outdir(classes)
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        String[] expect = {
+            "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5",
+            "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6",
+            "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7",
+            "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , "
+                + "(compiler.misc.location: kindname.class, p1.C1, null)",
+            "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , "
+                + "(compiler.misc.location: kindname.class, p1.C1, null)",
+            "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , "
+                + "(compiler.misc.location: kindname.class, p1.C1, null)"
+        };
+
+        for (String e: expect) {
+            if (!log.contains(e))
+                throw new Exception("expected output not found: " + e);
+        }
+    }
+
+    /*
+     * Set up the following module graph
+     *     m1 -> m2 => m3 => m4 -> m5
+     *              -> m6 => m7
+     * where -> is requires, => is requires transitive
+     */
+    Path getComplexSrc(Path base, String m1_extraImports, String m1_extraUses) throws Exception {
+        Path src = base.resolve("src");
+
+        Path src_m1 = src.resolve("m1");
+        tb.writeJavaFiles(src_m1,
+                "module m1 { requires m2; }",
+                "package p1;\n"
+                + "import p2.C2;\n"
+                + "import p3.C3;\n"
+                + "import p4.C4;\n"
+                + m1_extraImports
+                + "class C1 {\n"
+                + "  C2 c2; C3 c3; C4 c4;\n"
+                + m1_extraUses
+                + "}\n");
+
+        Path src_m2 = src.resolve("m2");
+        tb.writeJavaFiles(src_m2,
+                "module m2 {\n"
+                + "  requires transitive m3;\n"
+                + "  requires        m6;\n"
+                + "  exports p2;\n"
+                + "}",
+                "package p2;\n"
+                + "public class C2 { }\n");
+
+        Path src_m3 = src.resolve("m3");
+        tb.writeJavaFiles(src_m3,
+                "module m3 { requires transitive m4; exports p3; }",
+                "package p3;\n"
+                + "public class C3 { }\n");
+
+        Path src_m4 = src.resolve("m4");
+        tb.writeJavaFiles(src_m4,
+                "module m4 { requires m5; exports p4; }",
+                "package p4;\n"
+                + "public class C4 { }\n");
+
+        Path src_m5 = src.resolve("m5");
+        tb.writeJavaFiles(src_m5,
+                "module m5 { exports p5; }",
+                "package p5;\n"
+                + "public class C5 { }\n");
+
+        Path src_m6 = src.resolve("m6");
+        tb.writeJavaFiles(src_m6,
+                "module m6 { requires transitive m7; exports p6; }",
+                "package p6;\n"
+                + "public class C6 { }\n");
+
+        Path src_m7 = src.resolve("m7");
+        tb.writeJavaFiles(src_m7,
+                "module m7 { exports p7; }",
+                "package p7;\n"
+                + "public class C7 { }\n");
+
+        return src;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/modules/WeakModulesTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary tests for multi-module mode compilation
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jdeps/com.sun.tools.javap
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
+ * @run main WeakModulesTest
+ */
+
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.JavapTask;
+import toolbox.Task;
+import toolbox.Task.Expect;
+import toolbox.Task.OutputKind;
+
+public class WeakModulesTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new WeakModulesTest().runTests();
+    }
+
+    @Test
+    public void testWeakModule(Path base) throws Exception {
+        Path m1 = base.resolve("m1");
+        tb.writeJavaFiles(m1,
+                          "weak module m1 { }",
+                          "package api1; public class Api1 {}",
+                          "package api2; public class Api2 {}");
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        tb.createDirectories(m1Classes);
+
+        String log = new JavacTask(tb)
+                .outdir(m1Classes)
+                .files(findJavaFiles(m1))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.isEmpty())
+            throw new Exception("expected output not found: " + log);
+
+        String decompiled = new JavapTask(tb)
+                .options("--system", "none", "-bootclasspath", "")
+                .classpath(m1Classes.toString())
+                .classes("module-info")
+                .run()
+                .writeAll()
+                .getOutput(OutputKind.DIRECT)
+                .replace(System.getProperty("line.separator"), "\n");
+
+        String expected = "weak module m1 {\n" +
+                          "  requires java.base;\n" +
+                          "}";
+
+        if (!decompiled.contains(expected)) {
+            throw new Exception("expected output not found: " + decompiled);
+        }
+
+        //compiling against a weak module read from binary:
+        Path m2 = base.resolve("m2");
+        tb.writeJavaFiles(m2,
+                          "module m2 { requires m1; }",
+                          "package test; public class Test { api1.Api1 a1; api2.Api2 a2; }");
+        Path m2Classes = classes.resolve("m2");
+        tb.createDirectories(m2Classes);
+
+        String log2 = new JavacTask(tb)
+                .options("--module-path", m1Classes.toString())
+                .outdir(m2Classes)
+                .files(findJavaFiles(m2))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log2.isEmpty())
+            throw new Exception("expected output not found: " + log2);
+    }
+
+    @Test
+    public void testWeakModuleOnModuleSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        tb.writeJavaFiles(m1,
+                          "weak module m1 { }",
+                          "package api1; public class Api1 {}",
+                          "package api2; public class Api2 {}");
+        Path m2 = base.resolve("m2");
+        tb.writeJavaFiles(m2,
+                          "module m2 { requires m1; }",
+                          "package test; public class Test { api1.Api1 a1; api2.Api2 a2; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.isEmpty())
+            throw new Exception("expected output not found: " + log);
+    }
+
+    @Test
+    public void testNoExportsInWeakModules(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        tb.writeJavaFiles(m1,
+                          "weak module m1 { exports api1; }",
+                          "package api1; public class Api1 {}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("--module-source-path", src.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "module-info.java:1:18: compiler.err.no.exports.in.weak",
+                "1 error"
+        );
+        if (!expected.equals(log))
+            throw new Exception("expected output not found: " + log);
+    }
+
+}
--- a/test/tools/javac/options/release/ReleaseOptionClashes.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/options/release/ReleaseOptionClashes.java	Thu Sep 08 18:25:04 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug 8072480
  * @summary Verify option clash between --release and -source is reported correctly.
- * @modules jdk.compiler/com.sun.tools.javac.util
+ * @modules jdk.compiler/com.sun.tools.javac.util:private
  */
 
 import java.io.ByteArrayOutputStream;
--- a/test/tools/javac/parser/JavacParserTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/parser/JavacParserTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -370,7 +370,7 @@
     }
 
     @Test
-    void testCorrectWilcardPositions1() throws IOException {
+    void testCorrectWildcardPositions1() throws IOException {
         performWildcardPositionsTest("package test; import java.util.List; " +
                 "class Test { private void method() { List<? extends List<? extends String>> l; } }",
 
@@ -385,7 +385,7 @@
     }
 
     @Test
-    void testCorrectWilcardPositions2() throws IOException {
+    void testCorrectWildcardPositions2() throws IOException {
         performWildcardPositionsTest("package test; import java.util.List; "
                 + "class Test { private void method() { List<? super List<? super String>> l; } }",
                 Arrays.asList("List<? super List<? super String>> l;",
@@ -399,7 +399,7 @@
     }
 
     @Test
-    void testCorrectWilcardPositions3() throws IOException {
+    void testCorrectWildcardPositions3() throws IOException {
         performWildcardPositionsTest("package test; import java.util.List; " +
                 "class Test { private void method() { List<? super List<?>> l; } }",
 
@@ -413,7 +413,7 @@
     }
 
     @Test
-    void testCorrectWilcardPositions4() throws IOException {
+    void testCorrectWildcardPositions4() throws IOException {
         performWildcardPositionsTest("package test; import java.util.List; " +
                 "class Test { private void method() { " +
                 "List<? extends List<? extends List<? extends String>>> l; } }",
@@ -432,7 +432,7 @@
     }
 
     @Test
-    void testCorrectWilcardPositions5() throws IOException {
+    void testCorrectWildcardPositions5() throws IOException {
         performWildcardPositionsTest("package test; import java.util.List; " +
                 "class Test { private void method() { " +
                 "List<? extends List<? extends List<? extends String   >>> l; } }",
@@ -701,7 +701,7 @@
             }
         }.scan(cut, null);
 
-        assertEquals("testSwitchError: The Erroneous tree "
+        assertEquals("testOperatorMissingError: The Erroneous tree "
                 + "error values: " + values
                 + " do not match expected error values: "
                 + expectedValues, values, expectedValues);
@@ -726,7 +726,7 @@
             }
         }.scan(cut, null);
 
-        assertEquals("testSwitchError: The Erroneous tree "
+        assertEquals("testMissingParenthesisError: The Erroneous tree "
                 + "error values: " + values
                 + " do not match expected error values: "
                 + expectedValues, values, expectedValues);
@@ -751,7 +751,7 @@
             }
         }.scan(cut, null);
 
-        assertEquals("testSwitchError: The Erroneous tree "
+        assertEquals("testMissingClassError: The Erroneous tree "
                 + "error values: " + values
                 + " do not match expected error values: "
                 + expectedValues, values, expectedValues);
--- a/test/tools/javac/processing/model/TestSymtabItems.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/processing/model/TestSymtabItems.java	Thu Sep 08 18:25:04 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug 7021183 7025809
  * @summary 269: assertion failure getting enclosing element of an undefined name
- * @modules jdk.compiler/com.sun.tools.javac.code
+ * @modules jdk.compiler/com.sun.tools.javac.code:private
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.model
--- a/test/tools/javac/scope/DupUnsharedTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/scope/DupUnsharedTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary WriteableScope.dupUnshared not working properly for shared Scopes.
- * @modules jdk.compiler/com.sun.tools.javac.code
+ * @modules jdk.compiler/com.sun.tools.javac.code:private
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.util
  */
--- a/test/tools/javac/scope/HashCollisionTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/scope/HashCollisionTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -27,7 +27,7 @@
  * @summary Ensure Scope impl can cope with hash collisions
  * @library /tools/javac/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
- *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.code:private
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
--- a/test/tools/javac/types/ScopeListenerTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/javac/types/ScopeListenerTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8039262
  * @summary Ensure that using Types.membersClosure does not increase the number of listeners on the
  *          class's members Scope.
- * @modules jdk.compiler/com.sun.tools.javac.code
+ * @modules jdk.compiler/com.sun.tools.javac.code:private
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.util
  */
--- a/test/tools/jdeps/lib/ModuleMetaData.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/lib/ModuleMetaData.java	Thu Sep 08 18:25:04 2016 -0700
@@ -70,8 +70,8 @@
         return this;
     }
 
-    ModuleMetaData requiresPublic(String name) {
-        requires.put(name, new ModuleRequires(name, PUBLIC));
+    ModuleMetaData requiresTransitive(String name) {
+        requires.put(name, new ModuleRequires(name, TRANSITIVE));
         return this;
     }
 
--- a/test/tools/jdeps/modules/CheckModuleTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/modules/CheckModuleTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -100,7 +100,7 @@
             { "m4", new ModuleMetaData[] {
                         // original
                         new ModuleMetaData("m4")
-                            .requiresPublic("java.compiler")
+                            .requiresTransitive("java.compiler")
                             .requires("java.logging")
                             // unnused exports
                             .exports("p4.internal", Set.of("m6", "m7")),
@@ -115,21 +115,21 @@
             { "m5", new ModuleMetaData[] {
                         // original
                         new ModuleMetaData("m5")
-                            .requiresPublic("java.compiler")
-                            .requiresPublic("java.logging")
+                            .requiresTransitive("java.compiler")
+                            .requiresTransitive("java.logging")
                             .requires("java.sql")
-                            .requiresPublic("m4"),
+                            .requiresTransitive("m4"),
                         // suggested version
                         new ModuleMetaData("m5")
-                            .requiresPublic("java.compiler")
+                            .requiresTransitive("java.compiler")
                             .requires("java.logging")
-                            .requiresPublic("java.sql")
-                            .requiresPublic("m4"),
+                            .requiresTransitive("java.sql")
+                            .requiresTransitive("m4"),
                         // reduced version
                         new ModuleMetaData("m5")
-                            .requiresPublic("java.compiler")
-                            .requiresPublic("java.sql")
-                            .requiresPublic("m4"),
+                            .requiresTransitive("java.compiler")
+                            .requiresTransitive("java.sql")
+                            .requiresTransitive("m4"),
                     }
             },
         };
--- a/test/tools/jdeps/modules/GenModuleInfo.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/modules/GenModuleInfo.java	Thu Sep 08 18:25:04 2016 -0700
@@ -61,7 +61,8 @@
 
     // the names of the modules in this test
     private static final String UNSUPPORTED = "unsupported";
-    private static String[] modules = new String[] {"m1", "m2", "m3", UNSUPPORTED};
+    private static String[] modules = new String[] {"mI", "mII", "mIII", UNSUPPORTED};
+
     /**
      * Compiles all modules used by the test
      */
@@ -74,7 +75,7 @@
 
         assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
                                                "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
-        Arrays.asList("m1", "m2", "m3")
+        Arrays.asList("mI", "mII", "mIII")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
 
         Files.createDirectory(LIBS_DIR);
@@ -93,7 +94,7 @@
     }
 
     @Test
-    public void jdeps() throws IOException {
+    public void automaticModules() throws IOException {
         Stream<String> files = Arrays.stream(modules)
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
@@ -111,8 +112,8 @@
 
         // check file exists
         Arrays.stream(modules)
-                .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java"))
-                .forEach(f -> assertTrue(Files.exists(f)));
+             .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java"))
+             .forEach(f -> assertTrue(Files.exists(f)));
 
         // copy classes except the original module-info.class
         try (Stream<Path> stream = Files.walk(MODS_DIR, Integer.MAX_VALUE)) {
@@ -134,7 +135,7 @@
         assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR, UNSUPPORTED,
                         "-p", NEW_MODS_DIR.toString(), "-verbose",
                         "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
-        Arrays.asList("m1", "m2", "m3")
+        Arrays.asList("mI", "mII", "mIII")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR,
                                         mn, "-p", NEW_MODS_DIR.toString())));
 
--- a/test/tools/jdeps/modules/ModuleTest.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/modules/ModuleTest.java	Thu Sep 08 18:25:04 2016 -0700
@@ -58,7 +58,7 @@
 
     // the names of the modules in this test
     private static final String UNSUPPORTED = "unsupported";
-    private static String[] modules = new String[] {"m1", "m2", "m3", "m4", UNSUPPORTED};
+    private static String[] modules = new String[] {"mI", "mII", "mIII", "m4", UNSUPPORTED};
     /**
      * Compiles all modules used by the test
      */
@@ -70,37 +70,37 @@
         assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
                                                "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
         // m4 is not referenced
-        Arrays.asList("m1", "m2", "m3", "m4")
+        Arrays.asList("mI", "mII", "mIII", "m4")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
 
-        assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-p", MODS_DIR.toString()));
+        assertTrue(CompilerUtils.compile(SRC_DIR.resolve("mIII"), UNNAMED_DIR, "-p", MODS_DIR.toString()));
         Files.delete(UNNAMED_DIR.resolve("module-info.class"));
     }
 
     @DataProvider(name = "modules")
     public Object[][] expected() {
         return new Object[][]{
-                { "m3", new ModuleMetaData("m3").requiresPublic("java.sql")
-                            .requiresPublic("m2")
+                { "mIII", new ModuleMetaData("mIII").requiresTransitive("java.sql")
+                            .requiresTransitive("mII")
                             .requires("java.logging")
-                            .requiresPublic("m1")
+                            .requiresTransitive("mI")
                             .reference("p3", "java.lang", "java.base")
                             .reference("p3", "java.sql", "java.sql")
                             .reference("p3", "java.util.logging", "java.logging")
-                            .reference("p3", "p1", "m1")
-                            .reference("p3", "p2", "m2")
-                            .qualified("p3", "p2.internal", "m2")
+                            .reference("p3", "p1", "mI")
+                            .reference("p3", "p2", "mII")
+                            .qualified("p3", "p2.internal", "mII")
                 },
-                { "m2", new ModuleMetaData("m2").requiresPublic("m1")
+                { "mII", new ModuleMetaData("mII").requiresTransitive("mI")
                             .reference("p2", "java.lang", "java.base")
-                            .reference("p2", "p1", "m1")
+                            .reference("p2", "p1", "mI")
                             .reference("p2.internal", "java.lang", "java.base")
                             .reference("p2.internal", "java.io", "java.base")
                 },
-                { "m1", new ModuleMetaData("m1").requires("unsupported")
+                { "mI", new ModuleMetaData("mI").requires("unsupported")
                             .reference("p1", "java.lang", "java.base")
                             .reference("p1.internal", "java.lang", "java.base")
-                            .reference("p1.internal", "p1", "m1")
+                            .reference("p1.internal", "p1", "mI")
                             .reference("p1.internal", "q", "unsupported")
                 },
                 { "unsupported", new ModuleMetaData("unsupported")
@@ -115,7 +115,7 @@
         // jdeps --module-path mods -m <name>
         runTest(data, MODS_DIR.toString(), Set.of(name));
 
-        // jdeps --module-path libs/m1.jar:.... -m <name>
+        // jdeps --module-path libs/mI.jar:.... -m <name>
         String mp = Arrays.stream(modules)
                 .filter(mn -> !mn.equals(name))
                 .map(mn -> MODS_DIR.resolve(mn).toString())
@@ -129,21 +129,21 @@
                 { "unnamed", new ModuleMetaData("unnamed", false)
                             .depends("java.sql")
                             .depends("java.logging")
-                            .depends("m1")
-                            .depends("m2")
+                            .depends("mI")
+                            .depends("mII")
                             .reference("p3", "java.lang", "java.base")
                             .reference("p3", "java.sql", "java.sql")
                             .reference("p3", "java.util.logging", "java.logging")
-                            .reference("p3", "p1", "m1")
-                            .reference("p3", "p2", "m2")
-                            .internal("p3", "p2.internal", "m2")
+                            .reference("p3", "p1", "mI")
+                            .reference("p3", "p2", "mII")
+                            .internal("p3", "p2.internal", "mII")
                 },
         };
     }
 
     @Test(dataProvider = "unnamed")
     public void unnamedTest(String name, ModuleMetaData data) throws IOException {
-        runTest(data, MODS_DIR.toString(), Set.of("m1", "m2"), UNNAMED_DIR);
+        runTest(data, MODS_DIR.toString(), Set.of("mI", "mII"), UNNAMED_DIR);
     }
 
     private void runTest(ModuleMetaData data, String modulepath,
--- a/test/tools/jdeps/modules/src/m1/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m1 {
-    requires unsupported;
-    exports p1;
-}
--- a/test/tools/jdeps/modules/src/m1/p1/Goo.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public class Goo  {
-    public void name() {
-    }
-}
--- a/test/tools/jdeps/modules/src/m1/p1/Lib.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public class Lib {
-    public static boolean isPresent() {
-        return true;
-    }
-}
--- a/test/tools/jdeps/modules/src/m1/p1/S.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public interface S {
-    String name();
-}
--- a/test/tools/jdeps/modules/src/m1/p1/internal/Impl.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1.internal;
-
-import p1.S;
-
-public class Impl implements S {
-    public Impl() {
-        q.Counter.create("impl.counter");
-    }
-
-    public String name() {
-        return Impl.class.getName();
-    }
-}
--- a/test/tools/jdeps/modules/src/m2/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m2 {
-    requires public m1;
-    exports p2;
-    exports p2.internal to m3;
-}
--- a/test/tools/jdeps/modules/src/m2/p2/Bar.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2;
-
-import p1.Goo;
-
-public class Bar {
-    public Bar() {}
-
-    public Goo toGoo() {
-        return new Goo();
-    }
-}
--- a/test/tools/jdeps/modules/src/m2/p2/internal/T2.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2.internal;
-
-public class T2 {
-    public static void print() {
-        System.out.println("T2");
-    }
-}
--- a/test/tools/jdeps/modules/src/m3/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m3 {
-    requires public java.sql;
-    requires public m2;
-    requires java.logging;   // TODO: --gen-module-info to do transitive reduction
-    requires public m1;
-    exports p3;
-}
--- a/test/tools/jdeps/modules/src/m3/p3/Foo.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p3;
-
-import java.sql.Driver;
-import p1.Goo;
-import p2.Bar;
-
-public class Foo {
-    public Goo get(Bar bar) {
-        return bar.toGoo();
-    }
-
-    public Driver getDriver() { return null; }
-}
--- a/test/tools/jdeps/modules/src/m3/p3/Main.java	Thu Sep 08 17:42:01 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p3;
-
-import p2.internal.T2;
-
-public class Main {
-    public void run() {
-        T2.print();
-    }
-
-    public static void main(String... args) throws Exception {
-        Foo foo = new Foo();
-        foo.getDriver().getParentLogger().config("test");
-    }
-}
--- a/test/tools/jdeps/modules/src/m4/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/modules/src/m4/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -23,7 +23,7 @@
 
 module m4 {
     // not used in signature
-    requires public java.compiler;
+    requires transitive java.compiler;
 
     // unused dependence
     requires java.logging;
--- a/test/tools/jdeps/modules/src/m5/module-info.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/jdeps/modules/src/m5/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -22,15 +22,15 @@
  */
 
 module m5 {
-    // m4 requires public java.compiler
-    requires public m4;
-    requires public java.compiler;
+    // m4 requires transitive java.compiler
+    requires transitive m4;
+    requires transitive java.compiler;
 
-    // java.sql should be requires public
+    // java.sql should be requires transitive
     requires java.sql;
 
     // java.logging is used for implementation only
-    requires public java.logging;
+    requires transitive java.logging;
 
     exports p5;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mI/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module mI {
+    requires unsupported;
+    exports p1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mI/p1/Goo.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class Goo  {
+    public void name() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mI/p1/Lib.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class Lib {
+    public static boolean isPresent() {
+        return true;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mI/p1/S.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public interface S {
+    String name();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mI/p1/internal/Impl.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1.internal;
+
+import p1.S;
+
+public class Impl implements S {
+    public Impl() {
+        q.Counter.create("impl.counter");
+    }
+
+    public String name() {
+        return Impl.class.getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mII/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module mII {
+    requires transitive mI;
+    exports p2;
+    exports p2.internal to mIII;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mII/p2/Bar.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+
+import p1.Goo;
+
+public class Bar {
+    public Bar() {}
+
+    public Goo toGoo() {
+        return new Goo();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mII/p2/internal/T2.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2.internal;
+
+public class T2 {
+    public static void print() {
+        System.out.println("T2");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mIII/module-info.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module mIII {
+    requires transitive java.sql;
+    requires transitive mII;
+    requires java.logging;   // TODO: --gen-module-info to do transitive reduction
+    requires transitive mI;
+    exports p3;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mIII/p3/Foo.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+import java.sql.Driver;
+import p1.Goo;
+import p2.Bar;
+
+public class Foo {
+    public Goo get(Bar bar) {
+        return bar.toGoo();
+    }
+
+    public Driver getDriver() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/jdeps/modules/src/mIII/p3/Main.java	Thu Sep 08 18:25:04 2016 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+import p2.internal.T2;
+
+public class Main {
+    public void run() {
+        T2.print();
+    }
+
+    public static void main(String... args) throws Exception {
+        Foo foo = new Foo();
+        foo.getDriver().getParentLogger().config("test");
+    }
+}
--- a/test/tools/lib/toolbox/ModuleBuilder.java	Thu Sep 08 17:42:01 2016 -0700
+++ b/test/tools/lib/toolbox/ModuleBuilder.java	Thu Sep 08 18:25:04 2016 -0700
@@ -72,51 +72,132 @@
     }
 
     /**
-     * Adds a "requires public" directive to the declaration.
-     * @param requires the name of the module that is required
+     * Adds a "requires" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in while to locate the modules
+     *    if the declaration is compiled
+     * @return this builder
+     */
+    public ModuleBuilder requires(String module, Path... modulePath) {
+        addDirective(requires, "requires " + module + ";");
+        this.modulePath.addAll(Arrays.asList(modulePath));
+        return this;
+
+    }
+
+    /**
+     * Adds a "requires static" directive to the declaration.
+     * @param module the name of the module that is required
      * @param modulePath a path in which to locate the modules
      *    if the declaration is compiled
      * @return this builder
      */
-    public ModuleBuilder requiresPublic(String requires, Path... modulePath) {
-        this.requires.add("requires public " + requires + ";");
+    public ModuleBuilder requiresStatic(String module, Path... modulePath) {
+        addDirective(requires, "requires static " + module + ";");
         this.modulePath.addAll(Arrays.asList(modulePath));
         return this;
     }
 
     /**
-     * Adds a "requires" directive to the declaration.
-     * @param requires the name of the module that is required
-     * @param modulePath a path in while to locate the modules
+     * Adds a "requires transitive" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in which to locate the modules
      *    if the declaration is compiled
      * @return this builder
      */
-    public ModuleBuilder requires(String requires, Path... modulePath) {
-        this.requires.add("requires " + requires + ";");
+    public ModuleBuilder requiresTransitive(String module, Path... modulePath) {
+        addDirective(requires, "requires transitive " + module + ";");
         this.modulePath.addAll(Arrays.asList(modulePath));
         return this;
     }
 
     /**
+     * Adds a "requires static transitive" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in which to locate the modules
+     *    if the declaration is compiled
+     * @return this builder
+     */
+    public ModuleBuilder requiresStaticTransitive(String module, Path... modulePath) {
+        addDirective(requires, "requires static transitive " + module + ";");
+        this.modulePath.addAll(Arrays.asList(modulePath));
+        return this;
+    }
+
+    /**
+     * Adds an unqualified "exports" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exports(String pkg) {
+        return addDirective(exports, "exports " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports dynamic" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamic(String pkg) {
+        return addDirective(exports, "exports dynamic " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsPrivate(String pkg) {
+        return addDirective(exports, "exports private " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports dynamic private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamicPrivate(String pkg) {
+        return addDirective(exports, "exports dynamic private " + pkg + ";");
+    }
+
+    /**
      * Adds a qualified "exports" directive to the declaration.
      * @param pkg the name of the package to be exported
      * @param module the name of the module to which it is to be exported
      * @return this builder
      */
     public ModuleBuilder exportsTo(String pkg, String module) {
-        this.exports.add("exports " + pkg + " to " + module + ";");
-        return this;
+        return addDirective(exports, "exports " + pkg + " to " + module + ";");
     }
 
     /**
-     * Adds an unqualified "exports" directive to the declaration.
+     * Adds a qualified "exports dynamic" directive to the declaration.
      * @param pkg the name of the package to be exported
      * @param module the name of the module to which it is to be exported
      * @return this builder
      */
-    public ModuleBuilder exports(String pkg) {
-        this.exports.add("exports " + pkg + ";");
-        return this;
+    public ModuleBuilder exportsDynamicTo(String pkg, String module) {
+        return addDirective(exports, "exports dynamic " + pkg + " to " + module + ";");
+    }
+
+    /**
+     * Adds a qualified "exports private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @param module the name of the module to which it is to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsPrivateTo(String pkg, String module) {
+        return addDirective(exports, "exports private " + pkg + " to " + module + ";");
+    }
+
+    /**
+     * Adds a qualified "exports dynamic private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @param module the name of the module to which it is to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamicPrivateTo(String pkg, String module) {
+        return addDirective(exports, "exports dynamic private " + pkg + " to " + module + ";");
     }
 
     /**
@@ -125,8 +206,7 @@
      * @return this builder
      */
     public ModuleBuilder uses(String service) {
-        this.uses.add("uses " + service + ";");
-        return this;
+        return addDirective(uses, "uses " + service + ";");
     }
 
     /**
@@ -136,7 +216,11 @@
      * @return this builder
      */
     public ModuleBuilder provides(String service, String implementation) {
-        this.provides.add("provides " + service + " with " + implementation + ";");
+        return addDirective(provides, "provides " + service + " with " + implementation + ";");
+    }
+
+    private ModuleBuilder addDirective(List<String> directives, String directive) {
+        directives.add(directive);
         return this;
     }