changeset 4276:d218e1f84264

Merge
author mchung
date Sat, 27 Aug 2016 15:32:32 -0700
parents 398b154ca111 d1d80e52e44c
children 6844662f4290
files src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/module-info.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java src/jdk.javadoc/share/classes/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/lib/toolbox/ModuleBuilder.java
diffstat 52 files changed, 833 insertions(+), 561 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Sat Aug 27 15:32:32 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
@@ -145,7 +151,19 @@
      */
     interface ExportsDirective extends Directive {
         /**
-         * Returns the package being exported.
+         * Returns whether or not this is a dynamic exports.
+         * @return whether or not this is a dynamic exports
+         */
+        boolean isDynamic();
+
+        /**
+         * 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ExportsTree.java	Sat Aug 27 15:32:32 2016 -0700
@@ -34,13 +34,27 @@
  * <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 dynamic" directive.
+     * @return true if this is a "exports dynamic" directive
+     */
+    boolean isDynamic();
+
+    /**
+     * 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/RequiresTree.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/RequiresTree.java	Sat Aug 27 15:32:32 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/Directive.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java	Sat Aug 27 15:32:32 2016 -0700
@@ -76,7 +76,8 @@
 
     /** Flags for ExportsDirective. */
     public enum ExportsFlag {
-        DYNAMIC_PHASE(0x0040);
+        DYNAMIC_PHASE(0x0040),
+        PRIVATE_REFLECTION(0x0080);
 
         // overkill? move to ClassWriter?
         public static int value(Set<ExportsFlag> s) {
@@ -98,7 +99,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 +119,16 @@
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
+        public boolean isDynamic() {
+            return flags.contains(ExportsFlag.DYNAMIC_PHASE);
+        }
+
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
+        public boolean isPrivate() {
+            return flags.contains(ExportsFlag.PRIVATE_REFLECTION);
+        }
+
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public PackageElement getPackage() {
             return packge;
         }
@@ -187,7 +198,7 @@
     }
 
     /**
-     * 'requires' ['public'] ModuleName ';'
+     * 'requires' ('static' | 'transitive')* ModuleName ';'
      */
     public static class RequiresDirective extends Directive
             implements ModuleElement.RequiresDirective {
@@ -209,7 +220,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/comp/AttrContext.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Sat Aug 27 15:32:32 2016 -0700
@@ -633,11 +633,22 @@
 
         @Override
         public void visitExports(JCExports tree) {
-            Name name = TreeInfo.fullName(tree.qualid);
-            PackageSymbol packge = syms.enterPackage(sym, name);
-            attr.setPackageSymbols(tree.qualid, packge);
-            if (!allExports.add(packge)) {
-                log.error(tree.qualid.pos(), Errors.DuplicateExports(packge));
+            PackageSymbol packge;
+
+            if (tree.qualid == null) {
+                if (!tree.isDynamicPhase) {
+                    log.error(tree.pos(), Errors.DefaultExportsMustBeDynamic);
+                }
+                // TODO: more validity checking:
+                // must not conflict with other default exports
+                packge = null;
+            } else {
+                Name name = TreeInfo.fullName(tree.qualid);
+                packge = syms.enterPackage(sym, name);
+                attr.setPackageSymbols(tree.qualid, packge);
+                if (!allExports.add(packge)) {
+                    log.error(tree.qualid.pos(), Errors.DuplicateExports(packge));
+                }
             }
 
             List<ModuleSymbol> toModules = null;
@@ -655,8 +666,13 @@
             }
 
             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.isDynamicPhase) {
+                    flags.add(ExportsFlag.DYNAMIC_PHASE);
+                }
+                if (tree.isPrivate) {
+                    flags.add(ExportsFlag.PRIVATE_REFLECTION);
+                }
                 ExportsDirective d = new ExportsDirective(packge, toModules, flags);
                 tree.directive = d;
                 sym.exports = sym.exports.prepend(d);
@@ -747,7 +763,7 @@
 
         @Override
         public void visitExports(JCExports tree) {
-            if (tree.directive.packge.members().isEmpty()) {
+            if (tree.directive.packge != null && tree.directive.packge.members().isEmpty()) {
                 log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
             }
             msym.directives = msym.directives.prepend(tree.directive);
@@ -768,7 +784,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)) {
@@ -784,8 +807,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)) {
@@ -1024,7 +1045,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) {
@@ -1070,34 +1091,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 -XaddReads edges
-            requiresPublic = new HashSet<>();
+            requiresTransitive = new HashSet<>();
 
             Set<ModuleSymbol> seen = new HashSet<>();
             List<ModuleSymbol> todo = List.of(msym);
@@ -1107,14 +1130,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 {
@@ -1124,10 +1147,10 @@
                 }
             }
 
-            requiresPublic.remove(msym);
+            requiresTransitive.remove(msym);
         }
 
-        return requiresPublic;
+        return requiresTransitive;
     }
 
     private void initVisiblePackages(ModuleSymbol msym, Collection<ModuleSymbol> readable) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Sat Aug 27 15:32:32 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/ClassWriter.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Sat Aug 27 15:32:32 2016 -0700
@@ -966,7 +966,8 @@
         List<ExportsDirective> exports = m.exports;
         databuf.appendChar(exports.size());
         for (ExportsDirective e: exports) {
-            databuf.appendChar(pool.put(names.fromUtf(externalize(e.packge.flatName()))));
+            databuf.appendChar(e.packge == null ? 0 :
+                    pool.put(names.fromUtf(externalize(e.packge.flatName()))));
             databuf.appendChar(ExportsFlag.value(e.flags));
             if (e.modules == null) {
                 databuf.appendChar(0);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Sat Aug 27 15:32:32 2016 -0700
@@ -3212,16 +3212,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) {
@@ -3240,27 +3255,52 @@
             } 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;
+                boolean isPrivate = false;
+            loop:
+                while (true) {
+                    switch (token.kind) {
+                        case IDENTIFIER:
+                            if (token.name() == names.dynamic && !isDynamicPhase) {
+                                Token t1 = S.token(1);
+                                if (t1.kind == SEMI || t1.kind == DOT) {
+                                    break loop;
+                                }
+                                isDynamicPhase = true;
+                                break;
+                            } else {
+                                break loop;
+                            }
+                        case PRIVATE:
+                            if (isPrivate) {
+                                error(token.pos, "repeated.modifier");
+                            }
+                            isPrivate = true;
+                            break;
+                        default:
+                            break loop;
+                    }
+                    nextToken();
+                }
+                JCExpression pkgName;
+                switch (token.kind) {
+                    case DEFAULT:
+                        pkgName = null;
                         nextToken();
-                    }
+                        break;
+                    case IDENTIFIER:
+                        pkgName = qualident(false);
+                        break;
+                    default:
+                        reportSyntaxError(token.pos, "expected.identifier.or.default");
+                        pkgName = F.at(token.pos).Erroneous();
                 }
-                JCExpression pkgName = qualident(false);
                 List<JCExpression> moduleNames = null;
                 if (token.kind == IDENTIFIER && token.name() == names.to) {
                     nextToken();
                     moduleNames = qualidentList(false);
                 }
                 accept(SEMI);
-                defs.append(toP(F.at(pos).Exports(pkgName, isDynamicPhase, moduleNames)));
+                defs.append(toP(F.at(pos).Exports(pkgName, isDynamicPhase, 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Sat Aug 27 15:32:32 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.identifier.or.default=\
+    expected identifier or ''default''
+
 compiler.err.dot.class.expected=\
     ''.class'' expected
 
@@ -2733,6 +2736,9 @@
 compiler.err.duplicate.uses=\
     duplicate uses: {0}
 
+compiler.err.default.exports.must.be.dynamic=\
+    default exports must also specify ''dynamic''
+
 # 0: symbol
 compiler.err.service.implementation.is.abstract=\
     the service implementation is an abstract class: {0}
@@ -2757,10 +2763,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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Sat Aug 27 15:32:32 2016 -0700
@@ -2676,14 +2676,16 @@
 
     public static class JCExports extends JCDirective
             implements ExportsTree {
-        public JCExpression qualid;
+        public JCExpression qualid; // null for default
         public boolean isDynamicPhase;
+        public boolean isPrivate;
         public List<JCExpression> moduleNames;
         public ExportsDirective directive;
 
-        protected JCExports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
+        protected JCExports(JCExpression qualId, boolean isDynamicPhase, boolean isPrivate, List<JCExpression> moduleNames) {
             this.qualid = qualId;
             this.isDynamicPhase = isDynamicPhase;
+            this.isPrivate = isPrivate;
             this.moduleNames = moduleNames;
         }
 
@@ -2691,6 +2693,16 @@
         public void accept(Visitor v) { v.visitExports(this); }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
+        public boolean isDynamic() {
+            return isDynamicPhase;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public boolean isPrivate() {
+            return isPrivate;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.EXPORTS;
         }
@@ -2782,11 +2794,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;
         }
@@ -2968,7 +2985,7 @@
         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);
+        JCExports Exports(JCExpression qualId, boolean isDynamicPhase, 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Sat Aug 27 15:32:32 2016 -0700
@@ -458,6 +458,15 @@
     public void visitExports(JCExports tree) {
         try {
             print("exports ");
+            if (tree.isDynamicPhase)
+                print("dynamic ");
+            if (tree.isPrivate)
+                print("private ");
+            if (tree.qualid == null) {
+                print("default");
+            } else {
+                print(tree.qualid);
+            }
             printExpr(tree.qualid);
             if (tree.moduleNames != null) {
                 print(" to ");
@@ -486,8 +495,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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Sat Aug 27 15:32:32 2016 -0700
@@ -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.isDynamicPhase, t.isPrivate, moduleNames);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Sat Aug 27 15:32:32 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
@@ -545,8 +545,8 @@
     }
 
     @Override
-    public JCExports Exports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
-        JCExports tree = new JCExports(qualId, isDynamicPhase, moduleNames);
+    public JCExports Exports(JCExpression qualId, boolean isDynamicPhase, boolean isPrivate, List<JCExpression> moduleNames) {
+        JCExports tree = new JCExports(qualId, isDynamicPhase, isPrivate, moduleNames);
         tree.pos = pos;
         return tree;
     }
@@ -559,8 +559,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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Sat Aug 27 15:32:32 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,6 +69,7 @@
     public final Name provides;
     public final Name requires;
     public final Name to;
+    public final Name transitive;
     public final Name uses;
     public final Name with;
 
@@ -226,6 +227,7 @@
         provides = fromString("provides");
         requires = fromString("requires");
         to = fromString("to");
+        transitive = fromString("transitive");
         uses = fromString("uses");
         with = fromString("with");
 
--- a/src/jdk.compiler/share/classes/module-info.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.compiler/share/classes/module-info.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Sat Aug 27 15:32:32 2016 -0700
@@ -507,10 +507,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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.javadoc/share/classes/module-info.java	Sat Aug 27 15:32:32 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/Module_attribute.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java	Sat Aug 27 15:32:32 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,11 +36,12 @@
  *  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_DYNAMIC_PHASE       =   0x40;
+    public static final int ACC_PRIVATE_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);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Sat Aug 27 15:32:32 2016 -0700
@@ -540,9 +540,16 @@
         for (Module_attribute.ExportsEntry e: entries) {
             print("#" + e.exports_index + "," + String.format("%x", e.exports_flags));
             tab();
-            print("// " + constantWriter.stringValue(e.exports_index));
+            print("// ");
+            if (e.exports_index == 0) {
+                print("default");
+            } else {
+                print(constantWriter.stringValue(e.exports_index));
+            }
             if ((e.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
                 print(" ACC_DYNAMIC_PHASE");
+            if ((e.exports_flags & Module_attribute.ACC_PRIVATE_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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java	Sat Aug 27 15:32:32 2016 -0700
@@ -555,20 +555,27 @@
         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(getUTF8Value(entry.exports_index).replace('/', '.'));
+            print("exports");
             if ((entry.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
                 print(" dynamic");
+            if ((entry.exports_flags & Module_attribute.ACC_PRIVATE_REFLECTION) != 0)
+                print(" private");
+            print(" ");
+            if (entry.exports_index == 0) {
+                print("default");
+            } else {
+                print(getUTF8Value(entry.exports_index).replace('/', '.'));
+            }
             boolean first = true;
             for (int i: entry.exports_to_index) {
                 String mname;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/src/jdk.jshell/share/classes/module-info.java	Sat Aug 27 15:32:32 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/tools/javac/classfiles/attributes/Module/ModuleTest.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTest.java	Sat Aug 27 15:32:32 2016 -0700
@@ -140,9 +140,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 +160,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 { }");
@@ -230,16 +230,16 @@
                 .exportsTo("packTo1", "m2")
                 .exportsTo("packTo3", "m3", ExportFlag.DYNAMIC)
                 .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("packTo2", "java.compiler")
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Sat Aug 27 15:32:32 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,8 @@
     }
 
     enum ExportFlag implements Mask {
-        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE);
+        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE),
+        PRIVATE("private", Module_attribute.ACC_PRIVATE_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/DefaultExportsMustBeDynamic/module-info.java	Sat Aug 27 15:32:32 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.default.exports.must.be.dynamic
+
+module m {
+     exports default;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ExpectedIdentifierOrDefault/module-info.java	Sat Aug 27 15:32:32 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 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.identifier.or.default
+
+module m {
+    exports *;
+}
--- a/test/tools/javac/diags/examples/ServiceImplementationNoArgsConstructorNotPublic/exported/Service.java	Sat Aug 27 13:31:42 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	Sat Aug 27 13:31:42 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	Sat Aug 27 13:31:42 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/AutomaticModules.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/EdgeCases.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/GraphsTest.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/ModuleInfoTest.java	Sat Aug 27 15:32:32 2016 -0700
@@ -160,8 +160,14 @@
     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 { }");
+        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);
@@ -228,12 +234,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 +254,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 +288,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,7 +306,7 @@
                 .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");
     }
 
@@ -487,7 +493,13 @@
                     .writeAll()
                     .getOutput(Task.OutputKind.DIRECT);
 
-            if (!log.matches("(?s)^module\\-info\\.java:\\d+:\\d+: compiler\\.err\\.expected: token\\.identifier.*"))
+            String expect_prefix = "(?s)^module\\-info\\.java:\\d+:\\d+: ";
+            String expect_message = moduleInfo.contains("exports @")
+                ? "compiler\\.err\\.expected\\.identifier\\.or\\.default"
+                : "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");
         }
     }
--- a/test/tools/javac/modules/ModulePathTest.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/ModulePathTest.java	Sat Aug 27 15:32:32 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/ProvidesTest.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/ProvidesTest.java	Sat Aug 27 15:32:32 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/RequiresPublicTest.java	Sat Aug 27 13:31:42 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/javac/modules/RequiresStaticTest.java	Sat Aug 27 15:32:32 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	Sat Aug 27 15:32:32 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;
+    }
+}
--- a/test/tools/jdeps/lib/ModuleMetaData.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/lib/ModuleMetaData.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/CheckModuleTest.java	Sat Aug 27 15:32:32 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/ModuleTest.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/ModuleTest.java	Sat Aug 27 15:32:32 2016 -0700
@@ -80,10 +80,10 @@
     @DataProvider(name = "modules")
     public Object[][] expected() {
         return new Object[][]{
-                { "m3", new ModuleMetaData("m3").requiresPublic("java.sql")
-                            .requiresPublic("m2")
+                { "m3", new ModuleMetaData("m3").requiresTransitive("java.sql")
+                            .requiresTransitive("m2")
                             .requires("java.logging")
-                            .requiresPublic("m1")
+                            .requiresTransitive("m1")
                             .reference("p3", "java.lang", "java.base")
                             .reference("p3", "java.sql", "java.sql")
                             .reference("p3", "java.util.logging", "java.logging")
@@ -91,7 +91,7 @@
                             .reference("p3", "p2", "m2")
                             .qualified("p3", "p2.internal", "m2")
                 },
-                { "m2", new ModuleMetaData("m2").requiresPublic("m1")
+                { "m2", new ModuleMetaData("m2").requiresTransitive("m1")
                             .reference("p2", "java.lang", "java.base")
                             .reference("p2", "p1", "m1")
                             .reference("p2.internal", "java.lang", "java.base")
--- a/test/tools/jdeps/modules/src/m2/module-info.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/src/m2/module-info.java	Sat Aug 27 15:32:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 module m2 {
-    requires public m1;
+    requires transitive m1;
     exports p2;
     exports p2.internal to m3;
 }
--- a/test/tools/jdeps/modules/src/m3/module-info.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/src/m3/module-info.java	Sat Aug 27 15:32:32 2016 -0700
@@ -22,9 +22,9 @@
  */
 
 module m3 {
-    requires public java.sql;
-    requires public m2;
+    requires transitive java.sql;
+    requires transitive m2;
     requires java.logging;   // TODO: --gen-module-info to do transitive reduction
-    requires public m1;
+    requires transitive m1;
     exports p3;
 }
--- a/test/tools/jdeps/modules/src/m4/module-info.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/src/m4/module-info.java	Sat Aug 27 15:32:32 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	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/jdeps/modules/src/m5/module-info.java	Sat Aug 27 15:32:32 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;
 
--- a/test/tools/lib/toolbox/ModuleBuilder.java	Sat Aug 27 13:31:42 2016 -0700
+++ b/test/tools/lib/toolbox/ModuleBuilder.java	Sat Aug 27 15:32:32 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;
     }