changeset 4259:898ed6a0367f

Merge
author mchung
date Thu, 08 Sep 2016 17:42:01 -0700
parents 39138c7eeb27 dccf3761c661
children 03ab1221ab9e
files .hgtags src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java test/ProblemList.txt test/jdk/jshell/CommandCompletionTest.java test/jdk/jshell/CompletionSuggestionTest.java test/tools/javac/modules/RequiresStaticTest.java test/tools/javac/modules/UpgradeModulePathTest.java test/tools/javac/modules/XModuleTest.java test/tools/javac/platform/PlatformProviderTest.java test/tools/javac/sym/ElementStructureTest.java test/tools/javac/synthesize/Main.java test/tools/sjavac/Serialization.java
diffstat 69 files changed, 1670 insertions(+), 269 deletions(-) [+]
line wrap: on
line diff
--- a/.jcheck/conf	Thu Sep 08 21:11:55 2016 +0000
+++ b/.jcheck/conf	Thu Sep 08 17:42:01 2016 -0700
@@ -1,1 +1,4 @@
 project=jdk9
+comments=lax
+tags=lax
+bugids=dup
--- a/make/gensrc/GensrcCommon.gmk	Thu Sep 08 21:11:55 2016 +0000
+++ b/make/gensrc/GensrcCommon.gmk	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 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
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/ModuleTree.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ModuleTree.java	Thu Sep 08 17:42:01 2016 -0700
@@ -42,6 +42,12 @@
  */
 public interface ModuleTree extends Tree {
     /**
+     * Returns the annotations associated with this module declaration.
+     * @return the annotations
+     */
+    List<? extends AnnotationTree> getAnnotations();
+
+    /**
      * Returns the name of the module.
      * @return the name of the module
      */
--- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java	Thu Sep 08 17:42:01 2016 -0700
@@ -847,7 +847,8 @@
     }
 
     public R visitModule(ModuleTree node, P p) {
-        R r = scan(node.getName(), p);
+        R r = scan(node.getAnnotations(), p);
+        r = scanAndReduce(node.getName(), p, r);
         r = scanAndReduce(node.getDirectives(), p, r);
         return r;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java	Thu Sep 08 17:42:01 2016 -0700
@@ -53,7 +53,8 @@
 
     /** Flags for RequiresDirective. */
     public enum RequiresFlag {
-        PUBLIC(0x0020),
+        TRANSITIVE(0x0010),
+        STATIC_PHASE(0x0020),
         SYNTHETIC(0x1000),
         MANDATED(0x8000),
         EXTRA(0x10000);
@@ -73,16 +74,41 @@
         public final int value;
     }
 
+    /** Flags for ExportsDirective. */
+    public enum ExportsFlag {
+        DYNAMIC_PHASE(0x0040);
+
+        // overkill? move to ClassWriter?
+        public static int value(Set<ExportsFlag> s) {
+            int v = 0;
+            for (ExportsFlag f: s)
+                v |= f.value;
+            return v;
+        }
+
+        ExportsFlag(int value) {
+            this.value = value;
+        }
+
+        public final int value;
+    }
+
     /**
      * 'exports' Package ';'
      */
     public static class ExportsDirective extends Directive
             implements ModuleElement.ExportsDirective {
         public final PackageSymbol packge;
+        public final Set<ExportsFlag> flags;
         public final List<ModuleSymbol> modules;
 
         public ExportsDirective(PackageSymbol packge, List<ModuleSymbol> modules) {
+            this(packge, modules, EnumSet.noneOf(ExportsFlag.class));
+        }
+
+        public ExportsDirective(PackageSymbol packge, List<ModuleSymbol> modules, Set<ExportsFlag> flags) {
             this.packge = packge;
+            this.flags = flags;
             this.modules = modules;
         }
 
@@ -184,7 +210,7 @@
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public boolean isPublic() {
-            return flags.contains(RequiresFlag.PUBLIC);
+            return flags.contains(RequiresFlag.TRANSITIVE);
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Thu Sep 08 17:42:01 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
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu Sep 08 17:42:01 2016 -0700
@@ -237,6 +237,9 @@
             // TYPE_PARAMETER doesn't aid in distinguishing between
             // Type annotations and declaration annotations on an
             // Element
+        } else if (e.value.name == names.MODULE) {
+            if (s.kind == MDL)
+                return AnnotationType.DECLARATION;
         } else {
             Assert.error("annotationTargetType(): unrecognized Attribute name " + e.value.name +
                     " (" + e.value.name.getClass() + ")");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Sep 08 17:42:01 2016 -0700
@@ -45,6 +45,7 @@
 import java.util.*;
 
 import static com.sun.tools.javac.code.Flags.SYNTHETIC;
+import static com.sun.tools.javac.code.Kinds.Kind.MDL;
 import static com.sun.tools.javac.code.Kinds.Kind.MTH;
 import static com.sun.tools.javac.code.Kinds.Kind.VAR;
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
@@ -335,7 +336,7 @@
 
             // Note: @Deprecated has no effect on local variables and parameters
             if (!c.type.isErroneous()
-                    && toAnnotate.owner.kind != MTH
+                    && (toAnnotate.kind == MDL || toAnnotate.owner.kind != MTH)
                     && types.isSameType(c.type, syms.deprecatedType)) {
                 toAnnotate.flags_field |= Flags.DEPRECATED;
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Sep 08 17:42:01 2016 -0700
@@ -4429,6 +4429,15 @@
 
     public void visitModuleDef(JCModuleDecl tree) {
         tree.sym.completeUsesProvides();
+        ModuleSymbol msym = tree.sym;
+        Lint lint = env.outer.info.lint = env.outer.info.lint.augment(msym);
+        Lint prevLint = chk.setLint(lint);
+
+        try {
+            chk.checkDeprecatedModules(tree);
+        } finally {
+            chk.setLint(prevLint);
+        }
     }
 
     /** Finish the attribution of a class. */
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Sep 08 17:42:01 2016 -0700
@@ -60,6 +60,7 @@
 import static com.sun.tools.javac.code.TypeTag.WILDCARD;
 
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import com.sun.tools.javac.util.Log.DeferredDiagnosticHandler;
 
 /** Type checking helper class for the attribution phase.
  *
@@ -215,8 +216,13 @@
      *  @param sym        The deprecated symbol.
      */
     void warnDeprecated(DiagnosticPosition pos, Symbol sym) {
-        if (!lint.isSuppressed(LintCategory.DEPRECATION))
-            deprecationHandler.report(pos, "has.been.deprecated", sym, sym.location());
+        if (!lint.isSuppressed(LintCategory.DEPRECATION)) {
+            if (sym.kind == MDL) {
+                deprecationHandler.report(pos, "has.been.deprecated.module", sym);
+            } else {
+                deprecationHandler.report(pos, "has.been.deprecated", sym, sym.location());
+            }
+        }
     }
 
     /** Warn about unchecked operation.
@@ -3211,7 +3217,7 @@
     void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
         if ((s.flags() & DEPRECATED) != 0 &&
                 (other.flags() & DEPRECATED) == 0 &&
-                s.outermostClass() != other.outermostClass()) {
+                (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
             deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
                 @Override
                 public void report() {
@@ -3575,6 +3581,59 @@
         }
     }
 
+    /**
+     * Check for references to deprecated modules in module directives.
+     *
+     * @param tree
+     */
+    void checkDeprecatedModules(JCModuleDecl tree) {
+        ModuleSymbol msym = tree.sym;
+
+        class CheckVisitor extends JCTree.Visitor {
+            @Override
+            public void visitRequires(JCRequires tree) {
+                if (tree.directive != null) {
+                    checkDeprecated(tree.moduleName.pos(), msym, tree.directive.module);
+                }
+            }
+            @Override
+            public void visitExports(JCExports tree) {
+            if (tree.getModuleNames() != null) {
+                List<JCExpression> names = tree.getModuleNames();
+                List<ModuleSymbol> modules = tree.directive.modules;
+                while (modules.nonEmpty()) {
+                    DeferredDiagnosticHandler diag = new DeferredDiagnosticHandler(log);
+                    try {
+                        modules.head.complete();
+                    } finally {
+                        log.popDiagnosticHandler(diag);
+                        if (!diag.getDiagnostics().isEmpty()) {
+                            modules.head.completer = sym -> {
+                                for (JCDiagnostic d : diag.getDiagnostics()) {
+                                    log.report(d);
+                                }
+                            };
+                        }
+                    }
+                    checkDeprecated(names.head.pos(), msym, modules.head);
+                    names = names.tail;
+                    modules = modules.tail;
+                }
+            }
+            }
+            @Override
+            public void visitUses(JCUses that) {
+            }
+            @Override
+            public void visitProvides(JCProvides that) {
+            }
+        }
+
+        CheckVisitor v = new CheckVisitor();
+
+        tree.directives.forEach(directive -> directive.accept(v));
+    }
+
     public void checkImportsResolvable(final JCCompilationUnit toplevel) {
         for (final JCImport imp : toplevel.getImports()) {
             if (!imp.staticImport || !imp.qualid.hasTag(SELECT))
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -167,6 +167,9 @@
      */
     ListBuffer<ClassSymbol> uncompleted;
 
+    public boolean modulesInitialized;
+    ListBuffer<JCCompilationUnit> unfinishedModules = new ListBuffer<>();
+
     /** A dummy class to serve as enclClass for toplevel environments.
      */
     private JCClassDecl predefClassDef;
@@ -509,7 +512,9 @@
     public void visitModuleDef(JCModuleDecl tree) {
         Env<AttrContext> moduleEnv = moduleEnv(tree, env);
         typeEnvs.put(tree.sym, moduleEnv);
-        todo.append(moduleEnv);
+        if (modules.isInModuleGraph(tree.sym)) {
+            todo.append(moduleEnv);
+        }
     }
 
     /** Default class enter visitor method: do nothing.
@@ -552,7 +557,19 @@
                         prevUncompleted.append(clazz);
                 }
 
-                typeEnter.ensureImportsChecked(trees);
+                if (!modulesInitialized) {
+                    for (JCCompilationUnit cut : trees) {
+                        if (cut.getModuleDecl() != null) {
+                            unfinishedModules.append(cut);
+                        } else {
+                            typeEnter.ensureImportsChecked(List.of(cut));
+                        }
+                    }
+                } else {
+                    typeEnter.ensureImportsChecked(unfinishedModules.toList());
+                    unfinishedModules.clear();
+                    typeEnter.ensureImportsChecked(trees);
+                }
             }
         } finally {
             uncompleted = prevUncompleted;
@@ -562,5 +579,6 @@
 
     public void newRound() {
         typeEnvs.clear();
+        modulesInitialized = false;
     }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Sep 08 17:42:01 2016 -0700
@@ -2387,6 +2387,7 @@
     public void visitModuleDef(JCModuleDecl tree) {
         ModuleSymbol msym = tree.sym;
         ClassSymbol c = msym.module_info;
+        c.setAttributes(msym);
         c.flags_field |= Flags.MODULE;
         createInfoClass(List.<JCAnnotation>nil(), tree.sym.module_info);
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Sep 08 17:42:01 2016 -0700
@@ -54,6 +54,7 @@
 import com.sun.tools.javac.code.ClassFinder;
 import com.sun.tools.javac.code.Directive;
 import com.sun.tools.javac.code.Directive.ExportsDirective;
+import com.sun.tools.javac.code.Directive.ExportsFlag;
 import com.sun.tools.javac.code.Directive.RequiresDirective;
 import com.sun.tools.javac.code.Directive.RequiresFlag;
 import com.sun.tools.javac.code.Directive.UsesDirective;
@@ -109,7 +110,6 @@
 import static com.sun.tools.javac.code.Flags.ABSTRACT;
 import static com.sun.tools.javac.code.Flags.ENUM;
 import static com.sun.tools.javac.code.Flags.PUBLIC;
-import static com.sun.tools.javac.tree.JCTree.Tag.MODULEDEF;
 
 /**
  *  TODO: fill in
@@ -286,9 +286,9 @@
 
     private void enterModule(JCCompilationUnit toplevel, ClassSymbol c, Set<ModuleSymbol> modules) {
         boolean isModuleInfo = toplevel.sourcefile.isNameCompatible("module-info", Kind.SOURCE);
-        boolean isModuleDecl = toplevel.defs.nonEmpty() && toplevel.defs.head.hasTag(MODULEDEF);
+        boolean isModuleDecl = toplevel.getModuleDecl() != null;
         if (isModuleInfo && isModuleDecl) {
-            JCModuleDecl decl = (JCModuleDecl) toplevel.defs.head;
+            JCModuleDecl decl = toplevel.getModuleDecl();
             Name name = TreeInfo.fullName(decl.qualId);
             ModuleSymbol sym;
             if (c != null) {
@@ -349,8 +349,8 @@
                     if (locn != null) {
                         Name name = names.fromString(fileManager.inferModuleName(locn));
                         ModuleSymbol msym;
-                        if (tree.defs.head.hasTag(MODULEDEF)) {
-                            JCModuleDecl decl = (JCModuleDecl) tree.defs.head;
+                        JCModuleDecl decl = tree.getModuleDecl();
+                        if (decl != null) {
                             msym = decl.sym;
                             if (msym.name != name) {
                                 log.error(decl.qualId, Errors.ModuleNameMismatch(msym.name, name));
@@ -446,17 +446,14 @@
     }
 
     private Location getModuleLocation(JCCompilationUnit tree) throws IOException {
-        switch (tree.defs.head.getTag()) {
-            case MODULEDEF:
-                return getModuleLocation(tree.sourcefile, null);
-
-            case PACKAGEDEF:
-                JCPackageDecl pkg = (JCPackageDecl) tree.defs.head;
-                return getModuleLocation(tree.sourcefile, TreeInfo.fullName(pkg.pid));
-
-            default:
-                // code in unnamed module
-                return null;
+        if (tree.getModuleDecl() != null) {
+            return getModuleLocation(tree.sourcefile, null);
+        } else if (tree.getPackage() != null) {
+            JCPackageDecl pkg = tree.getPackage();
+            return getModuleLocation(tree.sourcefile, TreeInfo.fullName(pkg.pid));
+        } else {
+            // code in unnamed module
+            return null;
         }
     }
 
@@ -559,7 +556,7 @@
             if (ms == syms.unnamedModule || ms == msym)
                 continue;
             Set<RequiresFlag> flags = (ms.flags_field & Flags.AUTOMATIC_MODULE) != 0 ?
-                    EnumSet.of(RequiresFlag.PUBLIC) : EnumSet.noneOf(RequiresFlag.class);
+                    EnumSet.of(RequiresFlag.TRANSITIVE) : EnumSet.noneOf(RequiresFlag.class);
             RequiresDirective d = new RequiresDirective(ms, flags);
             directives.add(d);
             requires.add(d);
@@ -582,9 +579,10 @@
                 ModuleVisitor v = new ModuleVisitor();
                 JavaFileObject prev = log.useSource(tree.sourcefile);
                 try {
-                    tree.defs.head.accept(v);
-                    checkCyclicDependencies((JCModuleDecl) tree.defs.head);
+                    JCModuleDecl moduleDecl = tree.getModuleDecl();
+                    moduleDecl.accept(v);
                     completeModule(msym);
+                    checkCyclicDependencies(moduleDecl);
                 } finally {
                     log.useSource(prev);
                     msym.flags_field &= ~UNATTRIBUTED;
@@ -626,8 +624,10 @@
             } else {
                 allRequires.add(msym);
                 Set<RequiresFlag> flags = EnumSet.noneOf(RequiresFlag.class);
-                if (tree.isPublic)
-                    flags.add(RequiresFlag.PUBLIC);
+                if (tree.isTransitive)
+                    flags.add(RequiresFlag.TRANSITIVE);
+                if (tree.isStaticPhase)
+                    flags.add(RequiresFlag.STATIC_PHASE);
                 RequiresDirective d = new RequiresDirective(msym, flags);
                 tree.directive = d;
                 sym.requires = sym.requires.prepend(d);
@@ -645,7 +645,7 @@
 
             List<ModuleSymbol> toModules = null;
             if (tree.moduleNames != null) {
-                Set<ModuleSymbol> to = new HashSet<>();
+                Set<ModuleSymbol> to = new LinkedHashSet<>();
                 for (JCExpression n: tree.moduleNames) {
                     ModuleSymbol msym = lookupModule(n);
                     if (msym.kind != MDL) {
@@ -658,7 +658,9 @@
             }
 
             if (toModules == null || !toModules.isEmpty()) {
-                ExportsDirective d = new ExportsDirective(packge, toModules);
+                Set<ExportsFlag> flags = tree.isDynamicPhase
+                        ? EnumSet.of(ExportsFlag.DYNAMIC_PHASE) : Collections.emptySet();
+                ExportsDirective d = new ExportsDirective(packge, toModules, flags);
                 tree.directive = d;
                 sym.exports = sym.exports.prepend(d);
             }
@@ -709,7 +711,7 @@
             UsesProvidesVisitor v = new UsesProvidesVisitor(msym, env);
             JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
             try {
-                env.toplevel.defs.head.accept(v);
+                env.toplevel.getModuleDecl().accept(v);
             } finally {
                 log.useSource(prev);
             }
@@ -965,6 +967,10 @@
         allModules = result;
     }
 
+    public boolean isInModuleGraph(ModuleSymbol msym) {
+        return allModules == null || allModules.contains(msym);
+    }
+
     private Set<ModuleSymbol> computeTransitiveClosure(Iterable<? extends ModuleSymbol> base, Set<ModuleSymbol> observable) {
         List<ModuleSymbol> todo = List.nil();
 
@@ -1075,7 +1081,7 @@
             Set<ModuleSymbol> s = retrieveRequiresPublic(d.module);
             Assert.checkNonNull(s, () -> "no entry in cache for " + d.module);
             readable.addAll(s);
-            if (d.flags.contains(RequiresFlag.PUBLIC)) {
+            if (d.flags.contains(RequiresFlag.TRANSITIVE)) {
                 requiresPublic.add(d.module);
                 requiresPublic.addAll(s);
             }
@@ -1149,6 +1155,11 @@
                                     ModuleSymbol exportsFrom,
                                     Collection<ExportsDirective> exports) {
         for (ExportsDirective d : exports) {
+            // "exports dynamic ..." are not effective at compile-time
+            if (d.flags.contains(ExportsFlag.DYNAMIC_PHASE)) {
+                continue;
+            }
+
             if (d.modules == null || d.modules.contains(msym)) {
                 Name packageName = d.packge.fullname;
                 ModuleSymbol previousModule = seenPackages.get(packageName);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -162,8 +162,6 @@
         // if there remain any unimported toplevels (these must have
         // no classes at all), process their import statements as well.
         for (JCCompilationUnit tree : trees) {
-            if (tree.defs.nonEmpty() && tree.defs.head.hasTag(MODULEDEF))
-                continue;
             if (!tree.starImportScope.isFilled()) {
                 Env<AttrContext> topEnv = enter.topLevelEnv(tree);
                 finishImports(tree, () -> { completeClass.resolveImports(tree, topEnv); });
@@ -352,6 +350,15 @@
                 for (JCImport imp : tree.getImports()) {
                     doImport(imp);
                 }
+
+                if (tree.getModuleDecl() != null) {
+                    JCModuleDecl decl = tree.getModuleDecl();
+
+                    //check @Deprecated:
+                    markDeprecated(decl.sym, decl.annotations, env);
+                    // process module annotations
+                    annotate.annotateLater(decl.annotations, env, env.toplevel.modle, null);
+                }
             } finally {
                 this.env = prevEnv;
                 chk.setLint(prevLint);
@@ -746,13 +753,7 @@
                 }
             }
 
-            // Annotations.
-            // In general, we cannot fully process annotations yet,  but we
-            // can attribute the annotation types and then check to see if the
-            // @Deprecated annotation is present.
-            attr.attribAnnotationTypes(tree.mods.annotations, baseEnv);
-            if (hasDeprecatedAnnotation(tree.mods.annotations))
-                sym.flags_field |= DEPRECATED;
+            markDeprecated(sym, tree.mods.annotations, baseEnv);
 
             chk.checkNonCyclicDecl(tree);
         }
@@ -766,19 +767,6 @@
                 return superType;
             }
 
-            /**
-             * Check if a list of annotations contains a reference to
-             * java.lang.Deprecated.
-             **/
-            private boolean hasDeprecatedAnnotation(List<JCAnnotation> annotations) {
-                for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
-                    JCAnnotation a = al.head;
-                    if (a.annotationType.type == syms.deprecatedType && a.args.isEmpty())
-                        return true;
-                }
-                return false;
-            }
-
         @Override
         public void complete(Symbol sym) throws CompletionFailure {
             Assert.check((topLevelPhase instanceof ImportsPhase) ||
@@ -1123,4 +1111,29 @@
         List<JCExpression> typeargs = typarams.nonEmpty() ? make.Types(typarams) : null;
         return make.Exec(make.Apply(typeargs, meth, make.Idents(params)));
     }
+
+    /**
+     * Mark sym deprecated if annotations contain @Deprecated annotation.
+     */
+    public void markDeprecated(Symbol sym, List<JCAnnotation> annotations, Env<AttrContext> env) {
+        // In general, we cannot fully process annotations yet,  but we
+        // can attribute the annotation types and then check to see if the
+        // @Deprecated annotation is present.
+        attr.attribAnnotationTypes(annotations, env);
+        if (hasDeprecatedAnnotation(annotations))
+            sym.flags_field |= DEPRECATED;
+    }
+
+    /**
+     * Check if a list of annotations contains a reference to
+     * java.lang.Deprecated.
+     **/
+    private boolean hasDeprecatedAnnotation(List<JCAnnotation> annotations) {
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
+            JCAnnotation a = al.head;
+            if (a.annotationType.type == syms.deprecatedType && a.args.isEmpty())
+                return true;
+        }
+        return false;
+    }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Thu Sep 08 17:42:01 2016 -0700
@@ -29,6 +29,7 @@
 import java.io.InputStream;
 import java.lang.ref.SoftReference;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -127,7 +128,7 @@
 
     protected String classLoaderClass;
 
-    protected Locations locations;
+    protected final Locations locations;
 
     /**
      * A flag for clients to use to indicate that this file manager should
@@ -216,7 +217,10 @@
             addReadsMethod.invoke(thisModule, targetModule);
         } catch (NoSuchMethodException e) {
             // ignore
-        } catch (Exception e) {
+        } catch (IllegalAccessException
+                | IllegalArgumentException
+                | SecurityException
+                | InvocationTargetException e) {
             throw new Abort(e);
         }
         return targetLoader;
@@ -330,12 +334,12 @@
 
     @SuppressWarnings("cast")
     public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
-        String encodingName = getEncodingName();
+        String encName = getEncodingName();
         CharsetDecoder decoder;
         try {
-            decoder = getDecoder(encodingName, ignoreEncodingErrors);
+            decoder = getDecoder(encName, ignoreEncodingErrors);
         } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
-            log.error("unsupported.encoding", encodingName);
+            log.error("unsupported.encoding", encName);
             return (CharBuffer)CharBuffer.allocate(1).flip();
         }
 
@@ -371,7 +375,7 @@
                     unmappable.append(String.format("%02X", inbuf.get()));
                 }
 
-                String charsetName = charset == null ? encodingName : charset.name();
+                String charsetName = charset == null ? encName : charset.name();
 
                 log.error(dest.limit(),
                           Errors.IllegalCharForEncoding(unmappable.toString(), charsetName));
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 08 17:42:01 2016 -0700
@@ -583,6 +583,17 @@
         throw badClassFile("bad.module-info.name");
     }
 
+    /** Read exports_flags.
+     */
+    Set<ExportsFlag> readExportsFlags(int flags) {
+        Set<ExportsFlag> set = EnumSet.noneOf(ExportsFlag.class);
+        for (ExportsFlag f: ExportsFlag.values()) {
+            if ((flags & f.value) != 0)
+                set.add(f);
+        }
+        return set;
+    }
+
     /** Read requires_flags.
      */
     Set<RequiresFlag> readRequiresFlags(int flags) {
@@ -995,7 +1006,9 @@
 
             new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
                 protected void read(Symbol sym, int attrLen) {
-                    sym.flags_field |= DEPRECATED;
+                    Symbol s = sym.owner.kind == MDL ? sym.owner : sym;
+
+                    s.flags_field |= DEPRECATED;
                 }
             },
 
@@ -1243,6 +1256,7 @@
                         for (int i = 0; i < nexports; i++) {
                             Name n = readName(nextChar());
                             PackageSymbol p = syms.enterPackage(currentModule, names.fromUtf(internalize(n)));
+                            Set<ExportsFlag> flags = readExportsFlags(nextChar());
                             int nto = nextChar();
                             List<ModuleSymbol> to;
                             if (nto == 0) {
@@ -1253,7 +1267,7 @@
                                     lb.append(syms.enterModule(readName(nextChar())));
                                 to = lb.toList();
                             }
-                            exports.add(new ExportsDirective(p, to));
+                            exports.add(new ExportsDirective(p, to, flags));
                         }
                         msym.exports = exports.toList();
                         directives.addAll(msym.exports);
@@ -1549,7 +1563,13 @@
     }
 
     CompoundAnnotationProxy readCompoundAnnotation() {
-        Type t = readTypeOrClassSymbol(nextChar());
+        Type t;
+        if (currentModule.module_info == currentOwner) {
+            int index = poolIdx[nextChar()];
+            t = new ProxyType(Arrays.copyOfRange(buf, index + 3, index + 3 + getChar(index + 1)));
+        } else {
+            t = readTypeOrClassSymbol(nextChar());
+        }
         int numFields = nextChar();
         ListBuffer<Pair<Name,Attribute>> pairs = new ListBuffer<>();
         for (int i=0; i<numFields; i++) {
@@ -1899,14 +1919,18 @@
         }
 
         Attribute.Compound deproxyCompound(CompoundAnnotationProxy a) {
+            Type annotationType = a.type;
+            if (annotationType instanceof ProxyType) {
+                annotationType = ((ProxyType) annotationType).resolve();
+            }
             ListBuffer<Pair<Symbol.MethodSymbol,Attribute>> buf = new ListBuffer<>();
             for (List<Pair<Name,Attribute>> l = a.values;
                  l.nonEmpty();
                  l = l.tail) {
-                MethodSymbol meth = findAccessMethod(a.type, l.head.fst);
+                MethodSymbol meth = findAccessMethod(annotationType, l.head.fst);
                 buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd)));
             }
-            return new Attribute.Compound(a.type, buf.toList());
+            return new Attribute.Compound(annotationType, buf.toList());
         }
 
         MethodSymbol findAccessMethod(Type container, Name name) {
@@ -2076,7 +2100,11 @@
         AnnotationCompleter(Symbol sym, List<CompoundAnnotationProxy> l) {
             super(currentOwner.kind == MTH
                     ? currentOwner.enclClass() : (ClassSymbol)currentOwner);
-            this.sym = sym;
+            if (sym.kind == TYP && sym.owner.kind == MDL) {
+                this.sym = sym.owner;
+            } else {
+                this.sym = sym;
+            }
             this.l = l;
             this.classFile = currentClassFile;
         }
@@ -2485,7 +2513,7 @@
 
         minorVersion = nextChar();
         majorVersion = nextChar();
-        int maxMajor = Version.MAX().major;
+        int maxMajor = 53; // Version.MAX().major;  //******* TEMPORARY *******
         int maxMinor = Version.MAX().minor;
         if (majorVersion > maxMajor ||
             majorVersion * 1000 + minorVersion <
@@ -2527,6 +2555,8 @@
                 List<Type> found = foundTypeVariables;
                 missingTypeVariables = List.nil();
                 foundTypeVariables = List.nil();
+                interimUses = List.nil();
+                interimProvides = List.nil();
                 filling = false;
                 ClassType ct = (ClassType)currentOwner.type;
                 ct.supertype_field =
@@ -2788,6 +2818,31 @@
         }
     }
 
+    private class ProxyType extends Type {
+
+        private final byte[] content;
+
+        public ProxyType(byte[] content) {
+            super(syms.noSymbol, TypeMetadata.EMPTY);
+            this.content = content;
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return TypeTag.NONE;
+        }
+
+        @Override
+        public Type cloneWithMetadata(TypeMetadata metadata) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Type resolve() {
+            return sigToType(content, 0, content.length);
+        }
+
+    }
+
     private static final class InterimUsesDirective {
         public final Name service;
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -967,6 +967,7 @@
         databuf.appendChar(exports.size());
         for (ExportsDirective e: exports) {
             databuf.appendChar(pool.put(names.fromUtf(externalize(e.packge.flatName()))));
+            databuf.appendChar(ExportsFlag.value(e.flags));
             if (e.modules == null) {
                 databuf.appendChar(0);
             } else {
@@ -1766,12 +1767,20 @@
         acount += writeEnclosingMethodAttribute(c);
         if (c.owner.kind == MDL) {
             acount += writeModuleAttribute(c);
+            acount += writeFlagAttrs(c.owner.flags());
         }
         acount += writeExtraClassAttributes(c);
 
         poolbuf.appendInt(JAVA_MAGIC);
-        poolbuf.appendChar(target.minorVersion);
-        poolbuf.appendChar(target.majorVersion);
+
+        if (c.owner.kind == MDL) {
+            // temporarily overide to force use of v53 for module-info.class
+            poolbuf.appendChar(0);
+            poolbuf.appendChar(53);
+        } else {
+            poolbuf.appendChar(target.minorVersion);
+            poolbuf.appendChar(target.majorVersion);
+        }
 
         writePool(c.pool);
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1018,6 +1018,7 @@
 
     public List<JCCompilationUnit> initModules(List<JCCompilationUnit> roots) {
         modules.initModules(roots);
+        enter.modulesInitialized = true;
         if (roots.isEmpty()) {
             enterDone = true;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Sep 08 17:42:01 2016 -0700
@@ -3105,65 +3105,72 @@
         Token firstToken = token;
         JCModifiers mods = null;
         boolean consumedToplevelDoc = false;
+        boolean seenImport = false;
+        boolean seenPackage = false;
         ListBuffer<JCTree> defs = new ListBuffer<>();
-
-        if (token.kind == IDENTIFIER && token.name() == names.module) {
-            defs.append(moduleDecl(token.comment(CommentStyle.JAVADOC)));
+        if (token.kind == MONKEYS_AT)
+            mods = modifiersOpt();
+
+        if (token.kind == PACKAGE) {
+            int packagePos = token.pos;
+            List<JCAnnotation> annotations = List.nil();
+            seenPackage = true;
+            if (mods != null) {
+                checkNoMods(mods.flags);
+                annotations = mods.annotations;
+                mods = null;
+            }
+            nextToken();
+            JCExpression pid = qualident(false);
+            accept(SEMI);
+            JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid);
+            attach(pd, firstToken.comment(CommentStyle.JAVADOC));
             consumedToplevelDoc = true;
-        } else {
-            boolean seenImport = false;
-            boolean seenPackage = false;
-            if (token.kind == MONKEYS_AT)
-                mods = modifiersOpt();
-
-            if (token.kind == PACKAGE) {
-                int packagePos = token.pos;
-                List<JCAnnotation> annotations = List.nil();
-                seenPackage = true;
-                if (mods != null) {
-                    checkNoMods(mods.flags);
-                    annotations = mods.annotations;
-                    mods = null;
+            storeEnd(pd, token.pos);
+            defs.append(pd);
+        }
+
+        boolean checkForImports = true;
+        boolean firstTypeDecl = true;
+        while (token.kind != EOF) {
+            if (token.pos <= endPosTable.errorEndPos) {
+                // error recovery
+                skip(checkForImports, false, false, false);
+                if (token.kind == EOF)
+                    break;
+            }
+            if (checkForImports && mods == null && token.kind == IMPORT) {
+                seenImport = true;
+                defs.append(importDeclaration());
+            } else {
+                Comment docComment = token.comment(CommentStyle.JAVADOC);
+                if (firstTypeDecl && !seenImport && !seenPackage) {
+                    docComment = firstToken.comment(CommentStyle.JAVADOC);
+                    consumedToplevelDoc = true;
                 }
-                nextToken();
-                JCExpression pid = qualident(false);
-                accept(SEMI);
-                JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid);
-                attach(pd, firstToken.comment(CommentStyle.JAVADOC));
-                consumedToplevelDoc = true;
-                storeEnd(pd, token.pos);
-                defs.append(pd);
-            }
-            boolean checkForImports = true;
-            boolean firstTypeDecl = true;
-            while (token.kind != EOF) {
-                if (token.pos <= endPosTable.errorEndPos) {
-                    // error recovery
-                    skip(checkForImports, false, false, false);
-                    if (token.kind == EOF)
-                        break;
+                if (mods != null || token.kind != SEMI)
+                    mods = modifiersOpt(mods);
+                if (token.kind == IDENTIFIER && token.name() == names.module && firstTypeDecl) {
+                    List<JCAnnotation> annotations = List.nil();
+                    if (mods != null) {
+                        checkNoMods(mods.flags);
+                        annotations = mods.annotations;
+                        mods = null;
+                    }
+                    defs.append(moduleDecl(annotations, docComment));
+                    consumedToplevelDoc = true;
+                    break;
                 }
-                if (checkForImports && mods == null && token.kind == IMPORT) {
-                    seenImport = true;
-                    defs.append(importDeclaration());
-                } else {
-                    Comment docComment = token.comment(CommentStyle.JAVADOC);
-                    if (firstTypeDecl && !seenImport && !seenPackage) {
-                        docComment = firstToken.comment(CommentStyle.JAVADOC);
-                        consumedToplevelDoc = true;
-                    }
-                    JCTree def = typeDeclaration(mods, docComment);
-                    if (def instanceof JCExpressionStatement)
-                        def = ((JCExpressionStatement)def).expr;
-                    defs.append(def);
-                    if (def instanceof JCClassDecl)
-                        checkForImports = false;
-                    mods = null;
-                    firstTypeDecl = false;
-                }
+                JCTree def = typeDeclaration(mods, docComment);
+                if (def instanceof JCExpressionStatement)
+                    def = ((JCExpressionStatement)def).expr;
+                defs.append(def);
+                if (def instanceof JCClassDecl)
+                    checkForImports = false;
+                mods = null;
+                firstTypeDecl = false;
             }
         }
-
         JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(defs.toList());
         if (!consumedToplevelDoc)
             attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
@@ -3178,7 +3185,7 @@
         return toplevel;
     }
 
-    JCModuleDecl moduleDecl(Comment dc) {
+    JCModuleDecl moduleDecl(List<JCAnnotation> annotations, Comment dc) {
         int pos = token.pos;
         if (!allowModules) {
             log.error(pos, Errors.ModulesNotSupportedInSource(source.name));
@@ -3194,7 +3201,7 @@
         accept(RBRACE);
         accept(EOF);
 
-        JCModuleDecl result = toP(F.at(pos).ModuleDef(name, directives));
+        JCModuleDecl result = toP(F.at(pos).ModuleDef(annotations, name, directives));
         attach(result, dc);
         return result;
     }
@@ -3205,16 +3212,47 @@
             int pos = token.pos;
             if (token.name() == names.requires) {
                 nextToken();
-                boolean isPublic = false;
-                if (token.kind == PUBLIC) {
-                    isPublic = true;
+                boolean isTransitive = false;
+                boolean isStaticPhase = false;
+            loop:
+                while (true) {
+                    switch (token.kind) {
+                        case PUBLIC:
+                            if (isTransitive) {
+                                error(token.pos, "repeated.modifier");
+                            }
+                            isTransitive = true;
+                            break;
+                        case STATIC:
+                            if (isStaticPhase) {
+                                error(token.pos, "repeated.modifier");
+                            }
+                            isStaticPhase = true;
+                            break;
+                        default:
+                            break loop;
+                    }
                     nextToken();
                 }
                 JCExpression moduleName = qualident(false);
                 accept(SEMI);
-                defs.append(toP(F.at(pos).Requires(isPublic, moduleName)));
+                defs.append(toP(F.at(pos).Requires(isTransitive, isStaticPhase, moduleName)));
             } else if (token.name() == names.exports) {
                 nextToken();
+                boolean isDynamicPhase = false;
+                if (token.kind == IDENTIFIER && token.name() == names.dynamic) {
+                    // lookahead to see if dynamic is followed by a package name
+                    // (or if the token is itself the beginning of a package name)
+                    Token t1 = S.token(1);
+                    Token t2 = S.token(2);
+                    if (t1.kind == IDENTIFIER
+                            && (t2.kind == SEMI
+                                || t2.kind == DOT
+                                || t2.kind == IDENTIFIER && t2.name() == names.to)) {
+                        isDynamicPhase = true;
+                        nextToken();
+                    }
+                }
                 JCExpression pkgName = qualident(false);
                 List<JCExpression> moduleNames = null;
                 if (token.kind == IDENTIFIER && token.name() == names.to) {
@@ -3222,7 +3260,7 @@
                     moduleNames = qualidentList(false);
                 }
                 accept(SEMI);
-                defs.append(toP(F.at(pos).Exports(pkgName, moduleNames)));
+                defs.append(toP(F.at(pos).Exports(pkgName, isDynamicPhase, moduleNames)));
             } else if (token.name() == names.provides) {
                 nextToken();
                 JCExpression serviceName = qualident(false);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 08 17:42:01 2016 -0700
@@ -1442,6 +1442,10 @@
     {0} in {1} has been deprecated
 
 # 0: symbol
+compiler.warn.has.been.deprecated.module=\
+    module {0} has been deprecated
+
+# 0: symbol
 compiler.warn.sun.proprietary=\
     {0} is internal proprietary API and may be removed in a future release
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties	Thu Sep 08 17:42:01 2016 -0700
@@ -841,7 +841,7 @@
 
 ## All errors which do not refer to a particular line in the source code are
 ## preceded by this string.
-compiler.err.error=\u30A8\u30E9\u30FC: 
+compiler.err.error=\u30A8\u30E9\u30FC:
 
 # The following error messages do not refer to a line in the source code.
 compiler.err.cant.read.file={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093
@@ -1021,7 +1021,7 @@
 ## Warning messages may also include the following prefix to identify a
 ## lint option
 # 0: option name
-compiler.warn.lintOption=[{0}] 
+compiler.warn.lintOption=[{0}]
 
 # 0: symbol
 compiler.warn.constant.SVUID=serialVersionUID\u306F\u30AF\u30E9\u30B9{0}\u306E\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties	Thu Sep 08 17:42:01 2016 -0700
@@ -841,7 +841,7 @@
 
 ## All errors which do not refer to a particular line in the source code are
 ## preceded by this string.
-compiler.err.error=\u9519\u8BEF: 
+compiler.err.error=\u9519\u8BEF:
 
 # The following error messages do not refer to a line in the source code.
 compiler.err.cant.read.file=\u65E0\u6CD5\u8BFB\u53D6: {0}
@@ -927,7 +927,7 @@
 # 0: boolean, 1: symbol
 compiler.note.mref.stat.1=\u8F6C\u6362\u65B9\u6CD5\u5F15\u7528\n\u66FF\u4EE3 metafactory = {0}\nbridge \u65B9\u6CD5 = {1}
 
-compiler.note.note=\u6CE8: 
+compiler.note.note=\u6CE8:
 
 # 0: file name
 compiler.note.deprecated.filename={0}\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002
@@ -1016,12 +1016,12 @@
 ##
 
 ## All warning messages are preceded by the following string.
-compiler.warn.warning=\u8B66\u544A: 
+compiler.warn.warning=\u8B66\u544A:
 
 ## Warning messages may also include the following prefix to identify a
 ## lint option
 # 0: option name
-compiler.warn.lintOption=[{0}] 
+compiler.warn.lintOption=[{0}]
 
 # 0: symbol
 compiler.warn.constant.SVUID=serialVersionUID \u5728\u7C7B{0}\u4E2D\u5FC5\u987B\u662F\u5E38\u91CF
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 08 17:42:01 2016 -0700
@@ -527,6 +527,16 @@
         @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() { return Kind.COMPILATION_UNIT; }
 
+        public JCModuleDecl getModuleDecl() {
+            for (JCTree tree : defs) {
+                if (tree.hasTag(MODULEDEF)) {
+                    return (JCModuleDecl) tree;
+                }
+            }
+
+            return null;
+        }
+
         @DefinedBy(Api.COMPILER_TREE)
         public JCPackageDecl getPackage() {
             // PackageDecl must be the first entry if it exists
@@ -2619,11 +2629,13 @@
     }
 
     public static class JCModuleDecl extends JCTree implements ModuleTree {
+        public List<JCAnnotation> annotations;
         public JCExpression qualId;
         public List<JCDirective> directives;
         public ModuleSymbol sym;
 
-        protected JCModuleDecl(JCExpression qualId, List<JCDirective> directives) {
+        protected JCModuleDecl(List<JCAnnotation> annotations, JCExpression qualId, List<JCDirective> directives) {
+            this.annotations = annotations;
             this.qualId = qualId;
             this.directives = directives;
         }
@@ -2637,6 +2649,11 @@
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
+        public List<? extends AnnotationTree> getAnnotations() {
+            return annotations;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getName() {
             return qualId;
         }
@@ -2660,11 +2677,13 @@
     public static class JCExports extends JCDirective
             implements ExportsTree {
         public JCExpression qualid;
+        public boolean isDynamicPhase;
         public List<JCExpression> moduleNames;
         public ExportsDirective directive;
 
-        protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) {
+        protected JCExports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
             this.qualid = qualId;
+            this.isDynamicPhase = isDynamicPhase;
             this.moduleNames = moduleNames;
         }
 
@@ -2738,12 +2757,14 @@
 
     public static class JCRequires extends JCDirective
             implements RequiresTree {
-        public boolean isPublic;
+        public boolean isTransitive;
+        public boolean isStaticPhase;
         public JCExpression moduleName;
         public RequiresDirective directive;
 
-        protected JCRequires(boolean isPublic, JCExpression moduleName) {
-            this.isPublic = isPublic;
+        protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) {
+            this.isTransitive = isTransitive;
+            this.isStaticPhase = isStaticPhase;
             this.moduleName = moduleName;
         }
 
@@ -2762,7 +2783,7 @@
 
         @Override @DefinedBy(Api.COMPILER_TREE)
         public boolean isPublic() {
-            return isPublic;
+            return isTransitive;
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
@@ -2946,10 +2967,10 @@
         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
         JCErroneous Erroneous(List<? extends JCTree> errs);
-        JCModuleDecl ModuleDef(JCExpression qualId, List<JCDirective> directives);
-        JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames);
+        JCModuleDecl ModuleDef(List<JCAnnotation> annotations, JCExpression qualId, List<JCDirective> directives);
+        JCExports Exports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames);
         JCProvides Provides(JCExpression serviceName, JCExpression implName);
-        JCRequires Requires(boolean isPublic, JCExpression qualId);
+        JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
         JCUses Uses(JCExpression qualId);
         LetExpr LetExpr(List<JCVariableDecl> defs, JCExpression expr);
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Sep 08 17:42:01 2016 -0700
@@ -486,7 +486,7 @@
     public void visitRequires(JCRequires tree) {
         try {
             print("requires ");
-            if (tree.isPublic)
+            if (tree.isTransitive)
                 print("public ");
             printExpr(tree.moduleName);
             print(";");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Sep 08 17:42:01 2016 -0700
@@ -508,9 +508,10 @@
     @Override @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitModule(ModuleTree node, P p) {
         JCModuleDecl t = (JCModuleDecl) node;
+        List<JCAnnotation> annotations = copy(t.annotations, p);
         JCExpression qualId = copy(t.qualId);
         List<JCDirective> directives = copy(t.directives);
-        return M.at(t.pos).ModuleDef(qualId, directives);
+        return M.at(t.pos).ModuleDef(annotations, qualId, directives);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
@@ -518,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, moduleNames);
+        return M.at(t.pos).Exports(qualId, t.isDynamicPhase, moduleNames);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
@@ -533,7 +534,7 @@
     public JCRequires visitRequires(RequiresTree node, P p) {
         JCRequires t = (JCRequires) node;
         JCExpression moduleName = copy(t.moduleName, p);
-        return M.at(t.pos).Requires(t.isPublic, moduleName);
+        return M.at(t.pos).Requires(t.isTransitive, t.isStaticPhase, moduleName);
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Sep 08 17:42:01 2016 -0700
@@ -378,6 +378,11 @@
             return Position.NOPOS;
 
         switch(tree.getTag()) {
+            case MODULEDEF: {
+                JCModuleDecl md = (JCModuleDecl)tree;
+                return md.annotations.isEmpty() ? md.pos :
+                       md.annotations.head.pos;
+            }
             case PACKAGEDEF: {
                 JCPackageDecl pd = (JCPackageDecl)tree;
                 return pd.annotations.isEmpty() ? pd.pos :
@@ -769,8 +774,9 @@
         switch (node.getTag()) {
         case TOPLEVEL:
             JCCompilationUnit cut = (JCCompilationUnit) node;
-            if (isModuleInfo(cut) && cut.defs.nonEmpty() && cut.defs.head.hasTag(MODULEDEF))
-                return symbolFor(cut.defs.head);
+            JCModuleDecl moduleDecl = cut.getModuleDecl();
+            if (isModuleInfo(cut) && moduleDecl != null)
+                return symbolFor(moduleDecl);
             return cut.packge;
         case MODULEDEF:
             return ((JCModuleDecl) node).sym;
@@ -1158,7 +1164,7 @@
 
     public static boolean isModuleInfo(JCCompilationUnit tree) {
         return tree.sourcefile.isNameCompatible("module-info", JavaFileObject.Kind.SOURCE)
-                && tree.defs.nonEmpty() && tree.defs.head.hasTag(MODULEDEF);
+                && tree.getModuleDecl() != null;
     }
 
     public static JCModuleDecl getModule(JCCompilationUnit t) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Sep 08 17:42:01 2016 -0700
@@ -538,15 +538,15 @@
     }
 
     @Override
-    public JCModuleDecl ModuleDef(JCExpression qualid, List<JCDirective> directives) {
-        JCModuleDecl tree = new JCModuleDecl(qualid, directives);
+    public JCModuleDecl ModuleDef(List<JCAnnotation> annotations, JCExpression qualid, List<JCDirective> directives) {
+        JCModuleDecl tree = new JCModuleDecl(annotations, qualid, directives);
         tree.pos = pos;
         return tree;
     }
 
     @Override
-    public JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames) {
-        JCExports tree = new JCExports(qualId, moduleNames);
+    public JCExports Exports(JCExpression qualId, boolean isDynamicPhase, List<JCExpression> moduleNames) {
+        JCExports tree = new JCExports(qualId, isDynamicPhase, moduleNames);
         tree.pos = pos;
         return tree;
     }
@@ -559,8 +559,8 @@
     }
 
     @Override
-    public JCRequires Requires(boolean isPublic, JCExpression qualId) {
-        JCRequires tree = new JCRequires(isPublic, qualId);
+    public JCRequires Requires(boolean isPublic, boolean isStaticPhase, JCExpression qualId) {
+        JCRequires tree = new JCRequires(isPublic, isStaticPhase, qualId);
         tree.pos = pos;
         return tree;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Thu Sep 08 17:42:01 2016 -0700
@@ -73,6 +73,7 @@
 
     @Override
     public void visitModuleDef(JCModuleDecl tree) {
+        scan(tree.annotations);
         scan(tree.qualId);
         scan(tree.directives);
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Sep 08 17:42:01 2016 -0700
@@ -63,6 +63,7 @@
     public final Name _default;
     public final Name _super;
     public final Name _this;
+    public final Name dynamic;
     public final Name exports;
     public final Name module;
     public final Name provides;
@@ -167,6 +168,7 @@
     public final Name FIELD;
     public final Name LOCAL_VARIABLE;
     public final Name METHOD;
+    public final Name MODULE;
     public final Name PACKAGE;
     public final Name PARAMETER;
     public final Name TYPE;
@@ -218,6 +220,7 @@
         _default = fromString("default");
         _super = fromString("super");
         _this = fromString("this");
+        dynamic = fromString("dynamic");
         exports = fromString("exports");
         module = fromString("module");
         provides = fromString("provides");
@@ -323,6 +326,7 @@
         FIELD = fromString("FIELD");
         LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
         METHOD = fromString("METHOD");
+        MODULE = fromString("MODULE");
         PACKAGE = fromString("PACKAGE");
         PARAMETER = fromString("PARAMETER");
         TYPE = fromString("TYPE");
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties	Thu Sep 08 17:42:01 2016 -0700
@@ -99,7 +99,7 @@
 doclet.Subinterfaces=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8:
 doclet.Implementing_Classes=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8:
 doclet.Functional_Interface=\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
-doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002 
+doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
 doclet.also=\u540C\u69D8\u306B
 doclet.Frames=\u30D5\u30EC\u30FC\u30E0
 doclet.No_Frames=\u30D5\u30EC\u30FC\u30E0\u306A\u3057
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -549,6 +549,7 @@
             out.writeShort(attr.exports.length);
             for (Module_attribute.ExportsEntry e: attr.exports) {
                 out.writeShort(e.exports_index);
+                out.writeShort(e.exports_flags);
                 out.writeShort(e.exports_to_index.length);
                 for (int index: e.exports_to_index)
                     out.writeShort(index);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java	Thu Sep 08 17:42:01 2016 -0700
@@ -36,9 +36,11 @@
  *  deletion without notice.</b>
  */
 public class Module_attribute extends Attribute {
-    public static final int ACC_PUBLIC    =   0x20;
-    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_SYNTHETIC     = 0x1000;
+    public static final int ACC_MANDATED      = 0x8000;
 
     Module_attribute(ClassReader cr, int name_index, int length) throws IOException {
         super(name_index, length);
@@ -120,14 +122,16 @@
     public static class ExportsEntry {
         ExportsEntry(ClassReader cr) throws IOException {
             exports_index = cr.readUnsignedShort();
+            exports_flags = cr.readUnsignedShort();
             exports_to_count = cr.readUnsignedShort();
             exports_to_index = new int[exports_to_count];
             for (int i = 0; i < exports_to_count; i++)
                 exports_to_index[i] = cr.readUnsignedShort();
         }
 
-        public ExportsEntry(int index, int[] to) {
+        public ExportsEntry(int index, int flags, int[] to) {
             this.exports_index = index;
+            this.exports_flags = flags;
             this.exports_to_count = to.length;
             this.exports_to_index = to;
         }
@@ -137,6 +141,7 @@
         }
 
         public final int exports_index;
+        public final int exports_flags;
         public final int exports_to_count;
         public final int[] exports_to_index;
     }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -477,7 +477,6 @@
     @Override
     public Void visitMethodParameters(MethodParameters_attribute attr,
                                       Void ignore) {
-
         final String header = String.format(format, "Name", "Flags");
         println("MethodParameters:");
         indent(+1);
@@ -511,36 +510,48 @@
 
     protected void printRequiresTable(Module_attribute attr) {
         Module_attribute.RequiresEntry[] entries = attr.requires;
-        println(entries.length + "\t// " + "requires");
+        print(entries.length);
+        tab();
+        println("// " + "requires");
         indent(+1);
         for (Module_attribute.RequiresEntry e: entries) {
-            print("#" + e.requires_index + "," +
-                    String.format("%x", e.requires_flags)+ "\t// requires");
-            if ((e.requires_flags & Module_attribute.ACC_PUBLIC) != 0)
-                print(" public");
+            print("#" + e.requires_index + "," + String.format("%x", e.requires_flags));
+            tab();
+            print("// " + constantWriter.stringValue(e.requires_index));
+            if ((e.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
+                print(" ACC_TRANSITIVE");
+            if ((e.requires_flags & Module_attribute.ACC_STATIC_PHASE) != 0)
+                print(" ACC_STATIC_PHASE");
             if ((e.requires_flags & Module_attribute.ACC_SYNTHETIC) != 0)
-                print(" synthetic");
+                print(" ACC_SYNTHETIC");
             if ((e.requires_flags & Module_attribute.ACC_MANDATED) != 0)
-                print(" mandated");
-            println(" " + constantWriter.stringValue(e.requires_index));
+                print(" ACC_MANDATED");
+            println();
         }
         indent(-1);
     }
 
     protected void printExportsTable(Module_attribute attr) {
         Module_attribute.ExportsEntry[] entries = attr.exports;
-        println(entries.length + "\t// " + "exports");
+        print(entries.length);
+        tab();
+        println("// " + "exports");
         indent(+1);
         for (Module_attribute.ExportsEntry e: entries) {
-            print("#" + e.exports_index + "\t// exports");
-            print(" " + constantWriter.stringValue(e.exports_index));
+            print("#" + e.exports_index + "," + String.format("%x", e.exports_flags));
+            tab();
+            print("// " + constantWriter.stringValue(e.exports_index));
+            if ((e.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
+                print(" ACC_DYNAMIC_PHASE");
             if (e.exports_to_index.length == 0) {
                 println();
             } else {
                 println(" to ... " + e.exports_to_index.length);
                 indent(+1);
                 for (int to: e.exports_to_index) {
-                    println("#" + to + "\t// ... to " + constantWriter.stringValue(to));
+                    print("#" + to);
+                    tab();
+                    println("// ... to " + constantWriter.stringValue(to));
                 }
                 indent(-1);
             }
@@ -550,21 +561,29 @@
 
     protected void printUsesTable(Module_attribute attr) {
         int[] entries = attr.uses_index;
-        println(entries.length + "\t// " + "uses services");
+        print(entries.length);
+        tab();
+        println("// " + "uses");
         indent(+1);
         for (int e: entries) {
-            println("#" + e + "\t// uses " + constantWriter.stringValue(e));
+            print("#" + e);
+            tab();
+            println("// " + constantWriter.stringValue(e));
         }
         indent(-1);
     }
 
     protected void printProvidesTable(Module_attribute attr) {
         Module_attribute.ProvidesEntry[] entries = attr.provides;
-        println(entries.length + "\t// " + "provides services");
+        print(entries.length);
+        tab();
+        println("// " + "provides");
         indent(+1);
         for (Module_attribute.ProvidesEntry e: entries) {
             print("#" + e.provides_index + ",#" +
-                    e.with_index + "\t// provides ");
+                    e.with_index);
+            tab();
+            print("// ");
             print(constantWriter.stringValue(e.provides_index));
             print (" with ");
             println(constantWriter.stringValue(e.with_index));
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -555,8 +555,10 @@
         Module_attribute m = (Module_attribute) attr;
         for (Module_attribute.RequiresEntry entry: m.requires) {
             print("requires");
-            if ((entry.requires_flags & Module_attribute.ACC_PUBLIC) != 0)
+            if ((entry.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
                 print(" public");
+            if ((entry.requires_flags & Module_attribute.ACC_STATIC_PHASE) != 0)
+                print(" static");
             print(" ");
             print(getUTF8Value(entry.requires_index).replace('/', '.'));
             println(";");
@@ -565,6 +567,8 @@
         for (Module_attribute.ExportsEntry entry: m.exports) {
             print("exports ");
             print(getUTF8Value(entry.exports_index).replace('/', '.'));
+            if ((entry.exports_flags & Module_attribute.ACC_DYNAMIC_PHASE) != 0)
+                print(" dynamic");
             boolean first = true;
             for (int i: entry.exports_to_index) {
                 String mname;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java	Thu Sep 08 17:42:01 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(ModuleDescriptor.Requires.Modifier.PUBLIC, mn);
+                    builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.PUBLIC), mn);
                 } else {
                     builder.requires(mn);
                 }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Thu Sep 08 17:42:01 2016 -0700
@@ -163,12 +163,12 @@
             ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(root.name());
 
             if (!root.name().equals(JAVA_BASE))
-                builder.requires(MANDATED, JAVA_BASE);
+                builder.requires(Set.of(MANDATED), JAVA_BASE);
 
             requiresPublic.stream()
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
-                .forEach(mn -> builder.requires(PUBLIC, mn));
+                .forEach(mn -> builder.requires(Set.of(PUBLIC), mn));
 
             requires.stream()
                 .filter(m -> !requiresPublic.contains(m))
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n_ja.properties	Thu Sep 08 21:11:55 2016 +0000
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n_ja.properties	Thu Sep 08 17:42:01 2016 -0700
@@ -126,7 +126,7 @@
 
 jshell.console.see.more = <\u8A73\u7D30\u306F\u3001\u30BF\u30D6\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044>
 jshell.console.do.nothing = \u4F55\u3082\u3057\u306A\u3044
-jshell.console.choice = \u9078\u629E: 
+jshell.console.choice = \u9078\u629E:
 jshell.console.create.variable = \u5909\u6570\u306E\u4F5C\u6210
 jshell.console.resolvable = \n\u8B58\u5225\u5B50\u306F\u3053\u306E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3067\u89E3\u6C7A\u3067\u304D\u307E\u3059\u3002
 jshell.console.no.candidate = \n\u30A4\u30F3\u30DD\u30FC\u30C8\u3059\u308B\u5019\u88DC\u306E\u5B8C\u5168\u4FEE\u98FE\u3055\u308C\u305F\u540D\u524D\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
--- a/test/tools/javac/MethodParameters/AnnotationTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/AnnotationTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters AnnotationTest.java
  * @run main MethodParametersTester AnnotationTest AnnotationTest.out
  */
--- a/test/tools/javac/MethodParameters/AnonymousClass.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/AnonymousClass.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters AnonymousClass.java
  * @run main MethodParametersTester AnonymousClass AnonymousClass.out
  */
--- a/test/tools/javac/MethodParameters/Constructors.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/Constructors.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters Constructors.java
  * @run main MethodParametersTester Constructors Constructors.out
  */
--- a/test/tools/javac/MethodParameters/EnumTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/EnumTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters EnumTest.java
  * @run main MethodParametersTester EnumTest EnumTest.out
  */
--- a/test/tools/javac/MethodParameters/InstanceMethods.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/InstanceMethods.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters InstanceMethods.java
  * @run main MethodParametersTester InstanceMethods InstanceMethods.out
  */
--- a/test/tools/javac/MethodParameters/LambdaTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/LambdaTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582 8037546 8138729
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters LambdaTest.java
  * @run main MethodParametersTester LambdaTest LambdaTest.out
  */
--- a/test/tools/javac/MethodParameters/LocalClassTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/LocalClassTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters LocalClassTest.java
  * @run main MethodParametersTester LocalClassTest LocalClassTest.out
  */
--- a/test/tools/javac/MethodParameters/MemberClassTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/MemberClassTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters MemberClassTest.java
  * @run main MethodParametersTester MemberClassTest MemberClassTest.out
  */
--- a/test/tools/javac/MethodParameters/StaticMethods.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/StaticMethods.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters StaticMethods.java
  * @run main MethodParametersTester StaticMethods StaticMethods.out
  */
--- a/test/tools/javac/MethodParameters/UncommonParamNames.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/MethodParameters/UncommonParamNames.java	Thu Sep 08 17:42:01 2016 -0700
@@ -26,7 +26,7 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build MethodParametersTester
+ * @build MethodParametersTester ClassFileVisitor ReflectionVisitor
  * @compile -parameters UncommonParamNames.java
  * @run main MethodParametersTester UncommonParamNames UncommonParamNames.out
  */
--- a/test/tools/javac/T6435291/T6435291.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/T6435291/T6435291.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
--- a/test/tools/javac/api/6400303/T6400303.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/api/6400303/T6400303.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
--- a/test/tools/javac/api/TestResolveIdent.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/api/TestResolveIdent.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -24,8 +24,9 @@
 /*
  * @test
  * @summary Module attribute tests
- * @bug 8080878
- * @modules jdk.compiler/com.sun.tools.javac.api
+ * @bug 8080878 8161906 8162713
+ * @modules java.compiler
+ *          jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
  *          jdk.jdeps/com.sun.tools.classfile
@@ -56,7 +57,17 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exports("pack")
                 .write(base);
-        tb.writeJavaFiles(base, "package pack; public class C extends java.util.ArrayList{}");
+        tb.writeJavaFiles(base, "package pack; public class C extends java.util.ArrayList{ }");
+        compile(base);
+        testModuleAttribute(base, moduleDescriptor);
+    }
+
+    @Test
+    public void testDynamicExports(Path base) throws Exception {
+        ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
+                .exports("pack", ExportFlag.DYNAMIC)
+                .write(base);
+        tb.writeJavaFiles(base, "package pack; public class C extends java.util.ArrayList{ }");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -66,12 +77,16 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exports("pack")
                 .exports("pack2")
-                .exports("pack3")
+                .exports("pack3", ExportFlag.DYNAMIC)
+                .exports("pack4")
+                .exports("pack5", ExportFlag.DYNAMIC)
                 .write(base);
         tb.writeJavaFiles(base,
-                "package pack; public class A {}",
-                "package pack2; public class B {}",
-                "package pack3; public class C {}");
+                "package pack; public class A { }",
+                "package pack2; public class B { }",
+                "package pack3; public class C { }",
+                "package pack4; public class C { }",
+                "package pack5; public class C { }");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -81,7 +96,17 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exportsTo("pack", "jdk.compiler")
                 .write(base);
-        tb.writeJavaFiles(base, "package pack; public class A {}");
+        tb.writeJavaFiles(base, "package pack; public class A { }");
+        compile(base);
+        testModuleAttribute(base, moduleDescriptor);
+    }
+
+    @Test
+    public void testQualifiedDynamicExports(Path base) throws Exception {
+        ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
+                .exportsTo("pack", "jdk.compiler", ExportFlag.DYNAMIC)
+                .write(base);
+        tb.writeJavaFiles(base, "package pack; public class A { }");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -89,14 +114,18 @@
     @Test
     public void testSeveralQualifiedExports(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .exportsTo("pack", "jdk.compiler, java.xml")
-                .exportsTo("pack2", "java.xml")
+                .exportsTo("pack", "jdk.compiler, jdk.jdeps")
+                .exportsTo("pack2", "jdk.jdeps")
                 .exportsTo("pack3", "jdk.compiler")
+                .exportsTo("pack4", "jdk.compiler, jdk.jdeps", ExportFlag.DYNAMIC)
+                .exportsTo("pack5", "jdk.compiler", ExportFlag.DYNAMIC)
                 .write(base);
         tb.writeJavaFiles(base,
                 "package pack; public class A {}",
                 "package pack2; public class B {}",
-                "package pack3; public class C {}");
+                "package pack3; public class C {}",
+                "package pack4; public class C {}",
+                "package pack5; public class C {}");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -113,7 +142,16 @@
     @Test
     public void testRequiresPublic(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .requiresPublic("java.xml")
+                .requires("jdk.jdeps", RequiresFlag.PUBLIC)
+                .write(base);
+        compile(base);
+        testModuleAttribute(base, moduleDescriptor);
+    }
+
+    @Test
+    public void testRequiresStatic(Path base) throws Exception {
+        ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
+                .requires("jdk.jdeps", RequiresFlag.STATIC)
                 .write(base);
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
@@ -122,13 +160,20 @@
     @Test
     public void testSeveralRequires(Path base) throws Exception {
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
-                .requiresPublic("java.xml")
-                .requires("java.compiler")
+                .requires("jdk.jdeps", RequiresFlag.PUBLIC)
                 .requires("jdk.compiler")
-                .requiresPublic("jdk.scripting.nashorn")
-                .write(base);
-        compile(base);
-        testModuleAttribute(base, moduleDescriptor);
+                .requires("m2", RequiresFlag.STATIC)
+                .requires("m3")
+                .requires("m4", RequiresFlag.PUBLIC)
+                .requires("m5", RequiresFlag.STATIC, RequiresFlag.PUBLIC)
+                .write(base.resolve("m1"));
+        tb.writeJavaFiles(base.resolve("m2"), "module m2 { }");
+        tb.writeJavaFiles(base.resolve("m3"), "module m3 { }");
+        tb.writeJavaFiles(base.resolve("m4"), "module m4 { }");
+        tb.writeJavaFiles(base.resolve("m5"), "module m5 { }");
+        compile(base, "--module-source-path", base.toString(),
+                "-d", base.toString());
+        testModuleAttribute(base.resolve("m1"), moduleDescriptor);
     }
 
     @Test
@@ -136,7 +181,7 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .provides("java.util.Collection", "pack2.D")
                 .write(base);
-        tb.writeJavaFiles(base, "package pack2; public class D extends java.util.ArrayList{}");
+        tb.writeJavaFiles(base, "package pack2; public class D extends java.util.ArrayList{ }");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -146,15 +191,11 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .provides("java.util.Collection", "pack2.D")
                 .provides("java.util.List", "pack2.D")
-                .requires("java.logging")
-                .provides("java.util.logging.Logger", "pack2.C")
+                .requires("jdk.compiler")
+                .provides("com.sun.tools.javac.Main", "pack2.C")
                 .write(base);
-        tb.writeJavaFiles(base, "package pack2; public class D extends java.util.ArrayList{}",
-                "package pack2; public class C extends java.util.logging.Logger{ " +
-                        "public C() { super(\"\",\"\"); } \n" +
-                        "C(String a,String b){" +
-                        "    super(a,b);" +
-                        "}}");
+        tb.writeJavaFiles(base, "package pack2; public class D extends java.util.ArrayList{ }",
+                "package pack2; public class C extends com.sun.tools.javac.Main{ }");
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
     }
@@ -173,8 +214,8 @@
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .uses("java.util.List")
                 .uses("java.util.Collection")
-                .requires("java.logging")
-                .uses("java.util.logging.Logger")
+                .requires("jdk.compiler")
+                .uses("javax.tools.JavaCompiler")
                 .write(base);
         compile(base);
         testModuleAttribute(base, moduleDescriptor);
@@ -182,26 +223,45 @@
 
     @Test
     public void testComplex(Path base) throws Exception {
+        Path m1 = base.resolve("m1");
         ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1")
                 .exports("pack1")
-                .exportsTo("packTo1", "java.xml")
+                .exports("pack3", ExportFlag.DYNAMIC)
+                .exportsTo("packTo1", "m2")
+                .exportsTo("packTo3", "m3", ExportFlag.DYNAMIC)
                 .requires("jdk.compiler")
-                .requiresPublic("java.xml")
+                .requires("m2", RequiresFlag.PUBLIC)
+                .requires("m3", RequiresFlag.STATIC)
+                .requires("m4", RequiresFlag.PUBLIC, RequiresFlag.STATIC)
                 .provides("java.util.List", "pack1.C")
                 .uses("java.util.List")
                 .uses("java.nio.file.Path")
                 .provides("java.util.List", "pack2.D")
-                .requiresPublic("java.desktop")
+                .requires("jdk.jdeps", RequiresFlag.STATIC, RequiresFlag.PUBLIC)
+                .requires("m5", RequiresFlag.STATIC)
+                .requires("m6", RequiresFlag.PUBLIC)
                 .requires("java.compiler")
+                .exportsTo("packTo4", "java.compiler", ExportFlag.DYNAMIC)
                 .exportsTo("packTo2", "java.compiler")
+                .exports("pack4", ExportFlag.DYNAMIC)
                 .exports("pack2")
-                .write(base);
-        tb.writeJavaFiles(base, "package pack1; public class C extends java.util.ArrayList{}",
-                "package pack2; public class D extends java.util.ArrayList{}");
-        tb.writeJavaFiles(base,
+                .write(m1);
+        tb.writeJavaFiles(m1, "package pack1; public class C extends java.util.ArrayList{ }",
+                "package pack2; public class D extends java.util.ArrayList{ }",
+                "package pack3; public class D extends java.util.ArrayList{ }",
+                "package pack4; public class D extends java.util.ArrayList{ }");
+        tb.writeJavaFiles(m1,
                 "package packTo1; public class T1 {}",
-                "package packTo2; public class T2 {}");
-        compile(base);
-        testModuleAttribute(base, moduleDescriptor);
+                "package packTo2; public class T2 {}",
+                "package packTo3; public class T3 {}",
+                "package packTo4; public class T4 {}");
+        tb.writeJavaFiles(base.resolve("m2"), "module m2 { }");
+        tb.writeJavaFiles(base.resolve("m3"), "module m3 { }");
+        tb.writeJavaFiles(base.resolve("m4"), "module m4 { }");
+        tb.writeJavaFiles(base.resolve("m5"), "module m5 { }");
+        tb.writeJavaFiles(base.resolve("m6"), "module m6 { }");
+        compile(base, "--module-source-path", base.toString(),
+                "-d", base.toString());
+        testModuleAttribute(m1, moduleDescriptor);
     }
 }
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Thu Sep 08 17:42:01 2016 -0700
@@ -96,7 +96,9 @@
         for (Module_attribute.ExportsEntry export : module.exports) {
             String pkg = constantPool.getUTF8Value(export.exports_index);
             if (tr.checkTrue(moduleDescriptor.exports.containsKey(pkg), "Unexpected export " + pkg)) {
-                List<String> expectedTo = moduleDescriptor.exports.get(pkg);
+                Export expectedExport = moduleDescriptor.exports.get(pkg);
+                tr.checkEquals(expectedExport.mask, export.exports_flags, "Wrong export flags");
+                List<String> expectedTo = expectedExport.to;
                 tr.checkEquals(export.exports_to_count, expectedTo.size(), "Wrong amount of exports to");
                 List<String> actualTo = new ArrayList<>();
                 for (int toIdx : export.exports_to_index) {
@@ -145,6 +147,56 @@
     @interface Test {
     }
 
+    interface Mask {
+        int getMask();
+    }
+
+    enum RequiresFlag implements Mask {
+        PUBLIC("public", Module_attribute.ACC_TRANSITIVE),
+        STATIC("static", Module_attribute.ACC_STATIC_PHASE);
+
+        private final String token;
+        private final int mask;
+
+        RequiresFlag(String token, int mask) {
+            this.token = token;
+            this.mask = mask;
+        }
+
+        @Override
+        public int getMask() {
+            return mask;
+        }
+    }
+
+    enum ExportFlag implements Mask {
+        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE);
+
+        private final String token;
+        private final int mask;
+
+        ExportFlag(String token, int mask) {
+            this.token = token;
+            this.mask = mask;
+        }
+
+        @Override
+        public int getMask() {
+            return mask;
+        }
+    }
+
+    private class Export {
+        String pkg;
+        int mask;
+        List<String> to = new ArrayList<>();
+
+        public Export(String pkg, int mask) {
+            this.pkg = pkg;
+            this.mask = mask;
+        }
+    }
+
     class ModuleDescriptor {
 
         private final String name;
@@ -155,7 +207,7 @@
             requires.add(new Pair<>("java.base", Module_attribute.ACC_MANDATED));
         }
 
-        private final Map<String, List<String>> exports = new HashMap<>();
+        private final Map<String, Export> exports = new HashMap<>();
 
         //List of service and implementation
         private final List<Pair<String, String>> provides = new ArrayList<>();
@@ -170,37 +222,48 @@
             content.append(name).append('{').append('\n');
         }
 
-        public ModuleDescriptor requires(String... requires) {
-            for (String require : requires) {
-                this.requires.add(Pair.of(require, 0));
-                content.append("    requires ").append(require).append(LINE_END);
-            }
+        public ModuleDescriptor requires(String module) {
+            this.requires.add(Pair.of(module, 0));
+            content.append("    requires ").append(module).append(LINE_END);
+
             return this;
         }
 
-        public ModuleDescriptor requiresPublic(String... requiresPublic) {
-            for (String require : requiresPublic) {
-                this.requires.add(new Pair<>(require, Module_attribute.ACC_PUBLIC));
-                content.append("    requires public ").append(require).append(LINE_END);
+        public ModuleDescriptor requires(String module, RequiresFlag... flags) {
+            this.requires.add(new Pair<>(module, computeMask(flags)));
+
+            content.append("    requires ");
+            for (RequiresFlag flag : flags) {
+                content.append(flag.token).append(" ");
             }
+            content.append(module).append(LINE_END);
+
             return this;
         }
 
-        public ModuleDescriptor exports(String... exports) {
-            for (String export : exports) {
-                this.exports.putIfAbsent(export, new ArrayList<>());
-                content.append("    exports ").append(export).append(LINE_END);
+        public ModuleDescriptor exports(String pkg, ExportFlag... flags) {
+            this.exports.putIfAbsent(pkg, new Export(pkg, computeMask(flags)));
+            content.append("    exports ");
+            for (ExportFlag flag : flags) {
+                content.append(flag.token).append(" ");
             }
+            content.append(pkg).append(LINE_END);
             return this;
         }
 
-        public ModuleDescriptor exportsTo(String exports, String to) {
+        public ModuleDescriptor exportsTo(String pkg, String to, ExportFlag... flags) {
             List<String> tos = Pattern.compile(",")
                     .splitAsStream(to)
                     .map(String::trim)
                     .collect(Collectors.toList());
-            this.exports.computeIfAbsent(exports, k -> new ArrayList<>()).addAll(tos);
-            content.append("    exports ").append(exports).append(" to ").append(to).append(LINE_END);
+            this.exports.computeIfAbsent(pkg, k -> new Export(pkg, computeMask(flags)))
+                    .to.addAll(tos);
+
+            content.append("    exports ");
+            for (ExportFlag flag : flags) {
+                content.append(flag.token).append(" ");
+            }
+            content.append(pkg).append(" to ").append(to).append(LINE_END);
             return this;
         }
 
@@ -225,5 +288,12 @@
             tb.writeJavaFiles(path, src);
             return this;
         }
+
+        private int computeMask(Mask[] masks) {
+            return Arrays.stream(masks)
+                    .map(Mask::getMask)
+                    .reduce((a, b) -> a | b)
+                    .orElseGet(() -> 0);
+        }
     }
 }
--- a/test/tools/javac/defaultMethods/BadClassfile.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/defaultMethods/BadClassfile.java	Thu Sep 08 17:42:01 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/HasBeenDeprecatedModule/HasBeenDeprecatedModule.java	Thu Sep 08 17:42:01 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * 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.warn.has.been.deprecated.module
+//options: -Xlint:deprecation
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/HasBeenDeprecatedModule/modulesourcepath/m1/module-info.java	Thu Sep 08 17:42:01 2016 -0700
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+@Deprecated
+module m1 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/HasBeenDeprecatedModule/modulesourcepath/m2/module-info.java	Thu Sep 08 17:42:01 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+    requires m1;
+}
--- a/test/tools/javac/fatalErrors/NoJavaLangTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/fatalErrors/NoJavaLangTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -83,10 +83,13 @@
         // need to ensure there is an empty java.base to avoid different error message
         Files.createDirectories(Paths.get("modules/java.base"));
         new JavacTask(tb)
-                .sources("module java.base { }")
+                .sources("module java.base { }",
+                         "package java.lang; public class Object {}")
                 .outdir("modules/java.base")
                 .run();
 
+        Files.delete(Paths.get("modules", "java.base", "java", "lang", "Object.class"));
+
         // ideally we'd have a better message for this case
         String[] mpOpts = { "--system", "none", "--module-path", "modules" };
         test(mpOpts, compilerErrorMessage);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/modules/AnnotationsOnModules.java	Thu Sep 08 17:42:01 2016 -0700
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Test --add-modules and --limit-modules; also test the "enabled" modules.
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jdeps/com.sun.tools.classfile
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavaTask ModuleTestBase
+ * @run main AnnotationsOnModules
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
+import toolbox.JavacTask;
+import toolbox.Task.OutputKind;
+
+public class AnnotationsOnModules extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        AnnotationsOnModules t = new AnnotationsOnModules();
+        t.runTests();
+    }
+
+    @Test
+    public void testSimpleAnnotation(Path base) throws Exception {
+        Path moduleSrc = base.resolve("module-src");
+        Path m1 = moduleSrc.resolve("m1");
+
+        tb.writeJavaFiles(m1,
+                          "@Deprecated module m1 { }");
+
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        new JavacTask(tb)
+                .options("--module-source-path", moduleSrc.toString())
+                .outdir(modulePath)
+                .files(findJavaFiles(m1))
+                .run()
+                .writeAll();
+
+        ClassFile cf = ClassFile.read(modulePath.resolve("m1").resolve("module-info.class"));
+        RuntimeVisibleAnnotations_attribute annotations = (RuntimeVisibleAnnotations_attribute) cf.attributes.map.get(Attribute.RuntimeVisibleAnnotations);
+
+        if (annotations == null || annotations.annotations.length != 1) {
+            throw new AssertionError("Annotations not correct!");
+        }
+    }
+
+    @Test
+    public void testAnnotationWithImport(Path base) throws Exception {
+        Path moduleSrc = base.resolve("module-src");
+        Path m1 = moduleSrc.resolve("m1");
+
+        tb.writeJavaFiles(m1,
+                          "import m1.A; @A module m1 { }",
+                          "package m1; import java.lang.annotation.*; @Target(ElementType.MODULE) public @interface A {}");
+
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        new JavacTask(tb)
+                .options("--module-source-path", moduleSrc.toString())
+                .outdir(modulePath)
+                .files(findJavaFiles(m1))
+                .run()
+                .writeAll();
+
+        ClassFile cf = ClassFile.read(modulePath.resolve("m1").resolve("module-info.class"));
+        RuntimeInvisibleAnnotations_attribute annotations = (RuntimeInvisibleAnnotations_attribute) cf.attributes.map.get(Attribute.RuntimeInvisibleAnnotations);
+
+        if (annotations == null || annotations.annotations.length != 1) {
+            throw new AssertionError("Annotations not correct!");
+        }
+    }
+
+    @Test
+    public void testModuleInfoAnnotationsInAPI(Path base) throws Exception {
+        Path moduleSrc = base.resolve("module-src");
+        Path m1 = moduleSrc.resolve("m1");
+
+        tb.writeJavaFiles(m1,
+                          "import m1.*; @A @Deprecated @E @E module m1 { }",
+                          "package m1; import java.lang.annotation.*; @Target(ElementType.MODULE) public @interface A {}",
+                          "package m1; import java.lang.annotation.*; @Target(ElementType.MODULE) @Repeatable(C.class) public @interface E {}",
+                          "package m1; import java.lang.annotation.*; @Target(ElementType.MODULE) public @interface C { public E[] value(); }");
+
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        new JavacTask(tb)
+                .options("--module-source-path", moduleSrc.toString(),
+                         "-processor", AP.class.getName())
+                .outdir(modulePath)
+                .files(findJavaFiles(m1))
+                .run()
+                .writeAll();
+
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src,
+                          "class T {}");
+
+        Path out = base.resolve("out");
+
+        Files.createDirectories(out);
+
+        new JavacTask(tb)
+                .options("--module-path", modulePath.toString(),
+                         "--add-modules", "m1",
+                         "-processor", AP.class.getName())
+                .outdir(out)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+
+        new JavacTask(tb)
+                .options("--module-path", modulePath.toString() + File.pathSeparator + out.toString(),
+                         "--add-modules", "m1",
+                         "-processor", AP.class.getName(),
+                         "-proc:only")
+                .classes("m1/m1.A")
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+    }
+
+    @SupportedAnnotationTypes("*")
+    public static final class AP extends AbstractProcessor {
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            ModuleElement m1 = processingEnv.getElementUtils().getModuleElement("m1");
+            Set<String> actualAnnotations = new HashSet<>();
+            Set<String> expectedAnnotations =
+                    new HashSet<>(Arrays.asList("@m1.A", "@java.lang.Deprecated", "@m1.C({@m1.E, @m1.E})"));
+
+            for (AnnotationMirror am : m1.getAnnotationMirrors()) {
+                actualAnnotations.add(am.toString());
+            }
+
+            if (!expectedAnnotations.equals(actualAnnotations)) {
+                throw new AssertionError("Incorrect annotations: " + actualAnnotations);
+            }
+
+            return false;
+        }
+
+    }
+
+    @Test
+    public void testModuleDeprecation(Path base) throws Exception {
+        Path moduleSrc = base.resolve("module-src");
+        Path m1 = moduleSrc.resolve("m1");
+
+        tb.writeJavaFiles(m1,
+                          "@Deprecated module m1 { }");
+
+        Path m2 = moduleSrc.resolve("m2");
+
+        tb.writeJavaFiles(m2,
+                          "@Deprecated module m2 { }");
+
+        Path m3 = moduleSrc.resolve("m3");
+
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        List<String> actual;
+        List<String> expected;
+
+        for (String suppress : new String[] {"", "@Deprecated ", "@SuppressWarnings(\"deprecation\") "}) {
+            tb.writeJavaFiles(m3,
+                              suppress + "module m3 {\n" +
+                              "    requires m1;\n" +
+                              "    exports api to m1, m2;\n" +
+                              "}",
+                              "package api; public class Api { }");
+            actual = new JavacTask(tb)
+                    .options("--module-source-path", moduleSrc.toString(),
+                             "-XDrawDiagnostics")
+                    .outdir(modulePath)
+                    .files(findJavaFiles(moduleSrc))
+                    .run()
+                    .writeAll()
+                    .getOutputLines(OutputKind.DIRECT);
+
+            if (suppress.isEmpty()) {
+                expected = Arrays.asList(
+                        "- compiler.note.deprecated.filename: module-info.java",
+                        "- compiler.note.deprecated.recompile");
+            } else {
+                expected = Arrays.asList("");
+            }
+
+            if (!expected.equals(actual)) {
+                throw new AssertionError("Unexpected output: " + actual + "; suppress: " + suppress);
+            }
+
+            actual = new JavacTask(tb)
+                    .options("--module-source-path", moduleSrc.toString(),
+                             "-XDrawDiagnostics",
+                             "-Xlint:deprecation")
+                    .outdir(modulePath)
+                    .files(findJavaFiles(moduleSrc))
+                    .run()
+                    .writeAll()
+                    .getOutputLines(OutputKind.DIRECT);
+
+            if (suppress.isEmpty()) {
+                expected = Arrays.asList(
+                        "module-info.java:2:14: compiler.warn.has.been.deprecated.module: m1",
+                        "module-info.java:3:20: compiler.warn.has.been.deprecated.module: m1",
+                        "module-info.java:3:24: compiler.warn.has.been.deprecated.module: m2",
+                        "3 warnings");
+            } else {
+                expected = Arrays.asList("");
+            }
+
+            if (!expected.equals(actual)) {
+                throw new AssertionError("Unexpected output: " + actual + "; suppress: " + suppress);
+            }
+
+            //load the deprecated module-infos from classfile:
+            actual = new JavacTask(tb)
+                    .options("--module-path", modulePath.toString(),
+                             "-XDrawDiagnostics",
+                             "-Xlint:deprecation")
+                    .outdir(modulePath.resolve("m3"))
+                    .files(findJavaFiles(moduleSrc.resolve("m3")))
+                    .run()
+                    .writeAll()
+                    .getOutputLines(OutputKind.DIRECT);
+
+            if (!expected.equals(actual)) {
+                throw new AssertionError("Unexpected output: " + actual + "; suppress: " + suppress);
+            }
+        }
+    }
+
+}
--- a/test/tools/javac/modules/AutomaticModules.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/AutomaticModules.java	Thu Sep 08 17:42:01 2016 -0700
@@ -261,7 +261,7 @@
         Path moduleSrc = base.resolve("module-src");
 
         tb.writeJavaFiles(moduleSrc.resolve("m1"),
-                          "module m1 { requires automaticA; }",
+                          "module m1 { requires static automaticA; }",
                           "package impl; public class Impl { apiA.Api a; apiB.Api b; m2.M2 m;}");
 
         tb.writeJavaFiles(moduleSrc.resolve("m2"),
--- a/test/tools/javac/modules/ModuleInfoTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/ModuleInfoTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8158123
+ * @bug 8158123 8161906 8162713
  * @summary tests for module declarations
  * @library /tools/lib
  * @modules
@@ -154,6 +154,31 @@
     }
 
     /**
+     * Verify that dynamic exports are reported as missing.
+     */
+    @Test
+    public void testExportsDynamicNotFound(Path base) throws Exception {
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src.resolve("m1"), "module m1 { requires m2; }", "package pack1; public class B { pack.A a; }");
+        tb.writeJavaFiles(src.resolve("m2"), "module m2 { exports dynamic pack; }","package pack; public class A { }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("B.java:1:37: compiler.err.not.def.access.package.cant.access: pack.A, pack"))
+            throw new Exception("expected output not found");
+    }
+
+    /**
      * Verify that a simple loop is detected.
      */
     @Test
@@ -254,6 +279,32 @@
     }
 
     /**
+     * Verify that duplicate requires are detected.
+     */
+    @Test
+    public void testDuplicateRequiresPublicStatic(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; }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("module-info.java:1:49: compiler.err.duplicate.requires: m1"))
+            throw new Exception("expected output not found");
+    }
+
+    /**
      * Verify that duplicate exported packages are detected.
      */
     @Test
@@ -280,6 +331,29 @@
      * Verify that duplicate exported packages are detected.
      */
     @Test
+    public void testDuplicateDynamicExports_packages(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src, "module m1 { exports p; exports dynamic p; }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("module-info.java:1:40: compiler.err.duplicate.exports: p"))
+            throw new Exception("expected output not found");
+    }
+
+    /**
+     * Verify that duplicate exported packages are detected.
+     */
+    @Test
     public void testDuplicateExports_packages2(Path base) throws Exception {
         Path src = base.resolve("src");
         tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports p to m2; }");
@@ -304,6 +378,30 @@
      * Verify that duplicate exported packages are detected.
      */
     @Test
+    public void testDuplicateDynamicExports_packages2(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports dynamic p to m2; }");
+        tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("module-info.java:1:40: compiler.err.duplicate.exports: p"))
+            throw new Exception("expected output not found");
+    }
+
+    /**
+     * Verify that duplicate exported packages are detected.
+     */
+    @Test
     public void testDuplicateExports_modules(Path base) throws Exception {
         Path src = base.resolve("src");
         Path src_m1 = src.resolve("m1");
@@ -327,6 +425,32 @@
     }
 
     /**
+     * Verify that duplicate exported packages are detected.
+     */
+    @Test
+    public void testDuplicateDynamicExports_modules(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1");
+        tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
+        Path src_m2 = src.resolve("m2");
+        tb.writeFile(src_m2.resolve("module-info.java"), "module m2 { exports dynamic p to m1, m1; }");
+
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("module-info.java:1:38: compiler.err.duplicate.exports: m1"))
+            throw new Exception("expected output not found");
+    }
+
+    /**
      * Verify that annotations are not permitted at
      * any of the module names or the package names.
      */
--- a/test/tools/javac/modules/ModuleInfoTreeAccess.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/ModuleInfoTreeAccess.java	Thu Sep 08 17:42:01 2016 -0700
@@ -85,4 +85,29 @@
             assertNotNull("docCommentTree", docCommentTree);
         }
     }
+
+    @Test
+    public void testTreePathForModuleDeclWithImport(Path base) throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+            Path src = base.resolve("src");
+            tb.writeJavaFiles(src, "import java.lang.Deprecated; /** Test module */ @Deprecated module m1 {}");
+
+            Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src));
+            JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files);
+
+            task.analyze();
+            JavacTrees trees = JavacTrees.instance(task);
+            ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1");
+
+            TreePath path = trees.getPath(mdle);
+            assertNotNull("path", path);
+
+            ModuleElement mdle1 = (ModuleElement) trees.getElement(path);
+            assertNotNull("mdle1", mdle1);
+
+            DocCommentTree docCommentTree = trees.getDocCommentTree(mdle);
+            assertNotNull("docCommentTree", docCommentTree);
+        }
+    }
 }
--- a/test/tools/javac/modules/PackageConflictTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/PackageConflictTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -124,6 +124,31 @@
     }
 
     @Test
+    public void testConflictInDependenciesDynamicExport(Path base) throws Exception {
+        Path m1 = base.resolve("m1");
+        Path m2 = base.resolve("m2");
+        Path m3 = base.resolve("m3");
+        tb.writeJavaFiles(m1,
+                "module m1 { exports test; }",
+                "package test; public class A { }");
+        tb.writeJavaFiles(m2,
+                "module m2 { exports dynamic test; }",
+                "package test; public class B { }");
+        tb.writeJavaFiles(m3,
+                "module m3 { requires m1; requires m2; }",
+                "package impl; public class Impl { }");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        new JavacTask(tb)
+                .options("-XDrawDiagnostics", "--module-source-path", base.toString())
+                .outdir(classes)
+                .files(findJavaFiles(base))
+                .run(Task.Expect.SUCCESS)
+                .writeAll();
+    }
+
+    @Test
     public void testSimple2(Path base) throws Exception {
         Path modSrc = base.resolve("modSrc");
         Path modules = base.resolve("modules");
--- a/test/tools/javac/modules/ReportNonExistentPackageTest.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/ReportNonExistentPackageTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 /**
- * @test 8144342 8149658
+ * @test 8144342 8149658 8162713
  * @summary javac doesn't report errors if module exports non-existent package
  * @library /tools/lib
  * @modules
@@ -64,6 +64,24 @@
     }
 
     @Test
+    public void testExportDynamicUnknownPackage(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src, "module m { exports dynamic p1; }");
+        Path classes = base.resolve("classes");
+        Files.createDirectories(classes);
+
+        String log = new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("module-info.java:1:28: compiler.err.package.empty.or.not.found: p1"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
     public void testExportEmptyPackage(Path base) throws Exception {
         Path src = base.resolve("src");
         tb.writeJavaFiles(src,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/modules/RequiresStaticTest.java	Thu Sep 08 17:42:01 2016 -0700
@@ -0,0 +1,391 @@
+/*
+ * 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
+ * @bug 8161906 8161596
+ * @summary tests for "requires static"
+ * @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 RequiresStaticTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import toolbox.JavaTask;
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.Task.OutputKind;
+
+public class RequiresStaticTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        RequiresStaticTest t = new RequiresStaticTest();
+        t.runTests();
+    }
+
+    @Test
+    public void testJavaSE_OK(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "module m { requires static 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 static 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; import p8.C8;\n",
+                "C5 c5; C6 c6; C7 c7; C8 c8;\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:5:52: compiler.err.not.def.access.package.cant.access: p8.C8, p8",
+            "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)",
+            "C1.java:8:22: compiler.err.cant.resolve.location: kindname.class, C8, , , "
+                + "(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
+     *            \           /
+     *              \       /
+     *                v   v
+     *                  m6 => m7 --> m8
+     * where -> is requires, => is requires public, --> is requires static, -=-> is requires public static
+     */
+    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 static m6;\n"
+                + "  exports p2;\n"
+                + "}",
+                "package p2;\n"
+                + "public class C2 {p7.C7 c7; p6.C6 c6; p4.C4 c4;}\n");
+
+        Path src_m3 = src.resolve("m3");
+        tb.writeJavaFiles(src_m3,
+                "module m3 { requires public static m4; exports p3; }",
+                "package p3;\n"
+                + "public class C3 { }\n");
+
+        Path src_m4 = src.resolve("m4");
+        tb.writeJavaFiles(src_m4,
+                "module m4 { requires m5; requires static m6; exports p4; }",
+                "package p4;\n"
+                + "public class C4 { p6.C6 c6; p7.C7 c7;}\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 { p7.C7 c7; }\n");
+
+        Path src_m7 = src.resolve("m7");
+        tb.writeJavaFiles(src_m7,
+                "module m7 { requires static m8; exports p7; }",
+                "package p7;\n"
+                + "public class C7 { p8.C8 c8; }\n");
+
+        Path src_m8 = src.resolve("m8");
+        tb.writeJavaFiles(src_m8,
+                "module m8 { exports p8; }",
+                "package p8;\n"
+                        + "public class C8 { }\n");
+
+        return src;
+    }
+
+    @Test
+    public void testRequiresStatic(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        tb.writeJavaFiles(m1,
+                "module m1 { exports m1; }",
+                "package m1;" +
+                "public class Api { }\n");
+
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        Files.createDirectories(m1Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .files(findJavaFiles(m1))
+                .outdir(m1Classes)
+                .run()
+                .writeAll();
+
+        Path m3 = src.resolve("m3");
+        tb.writeJavaFiles(m3,
+                "module m3 { requires static m1; }",
+                "package m3;\n" +
+                "public class Test {\n" +
+                "    public static void main(String... args) {\n" +
+                "        try {\n" +
+                "           Class.forName(\"m1.Api\");\n" +
+                "        } catch (ClassNotFoundException e) {\n" +
+                "            System.err.println(\"ok\");\n" +
+                "        }\n" +
+                "    }\n" +
+                "}",
+                "package m3;\n" +
+                "public class ApiUse{\n" +
+                "    m1.Api api;\n" +
+                "}");
+
+        Path m3Classes = classes.resolve("m3");
+        Files.createDirectories(m3Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("--module-path", m1Classes.toString())
+                .files(findJavaFiles(m3))
+                .outdir(m3Classes)
+                .run()
+                .writeAll();
+
+        String log = new JavaTask(tb)
+                .vmOptions("--module-path", m3Classes.toString(), "--add-modules", "m3")
+                .className("m3.Test")
+                .run()
+                .writeAll()
+                .getOutput(OutputKind.STDERR);
+
+        String expected = "ok" + System.getProperty("line.separator");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testRequiresPublicStatic(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        tb.writeJavaFiles(m1,
+                "module m1 { exports m1; }",
+                "package m1;" +
+                "public class Api { }\n");
+
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        Files.createDirectories(m1Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .files(findJavaFiles(m1))
+                .outdir(m1Classes)
+                .run()
+                .writeAll();
+
+        Path m2 = src.resolve("m2");
+        tb.writeJavaFiles(m2,
+                "module m2 { requires public static m1; }");
+
+        Path m2Classes = classes.resolve("m2");
+        Files.createDirectories(m2Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("--module-path", m1Classes.toString())
+                .files(findJavaFiles(m2))
+                .outdir(m2Classes)
+                .run()
+                .writeAll();
+
+        Path m3 = src.resolve("m3");
+        tb.writeJavaFiles(m3,
+                "module m3 { requires m2; }",
+                "package m3;\n" +
+                "public class Test {\n" +
+                "    public static void main(String... args) {\n" +
+                "        try {\n" +
+                "           Class.forName(\"m1.Api\");\n" +
+                "        } catch (ClassNotFoundException e) {\n" +
+                "            System.err.println(\"ok\");\n" +
+                "        }\n" +
+                "    }\n" +
+                "}",
+                "package m3;\n" +
+                "public class ApiUse{\n" +
+                "    m1.Api api;\n" +
+                "}");
+
+        Path m3Classes = classes.resolve("m3");
+        Files.createDirectories(m3Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("--module-path", m1Classes.toString() + File.pathSeparator + m2Classes.toString())
+                .files(findJavaFiles(m3))
+                .outdir(m3Classes)
+                .run()
+                .writeAll();
+
+        String log = new JavaTask(tb)
+                .vmOptions("--module-path", m2Classes.toString() + File.pathSeparator + m3Classes.toString(),
+                           "--add-modules", "m3")
+                .className("m3.Test")
+                .run()
+                .writeAll()
+                .getOutput(OutputKind.STDERR);
+
+        String expected = "ok" + System.getProperty("line.separator");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testRequiresStaticPublic(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        tb.writeJavaFiles(m1,
+                "module m1 { exports m1; }",
+                "package m1;" +
+                "public class Api { }\n");
+
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        Files.createDirectories(m1Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .files(findJavaFiles(m1))
+                .outdir(m1Classes)
+                .run()
+                .writeAll();
+
+        Path m2 = src.resolve("m2");
+        tb.writeJavaFiles(m2,
+                "module m2 { requires public static m1; }");
+
+        Path m2Classes = classes.resolve("m2");
+        Files.createDirectories(m2Classes);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("--module-path", m1Classes.toString())
+                .files(findJavaFiles(m2))
+                .outdir(m2Classes)
+                .run()
+                .writeAll();
+    }
+}
--- a/test/tools/javac/modules/T8158224/Processor.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/modules/T8158224/Processor.java	Thu Sep 08 17:42:01 2016 -0700
@@ -37,4 +37,4 @@
     public boolean process(Set<? extends TypeElement> tE, RoundEnvironment env) {
         return true;
     }
-}
\ No newline at end of file
+}
--- a/test/tools/javac/scope/IterateAndRemove.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/javac/scope/IterateAndRemove.java	Thu Sep 08 17:42:01 2016 -0700
@@ -103,4 +103,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
--- a/test/tools/sjavac/Serialization.java	Thu Sep 08 21:11:55 2016 +0000
+++ b/test/tools/sjavac/Serialization.java	Thu Sep 08 17:42:01 2016 -0700
@@ -61,7 +61,7 @@
                 Option.SRC.arg, "root",
                 Option.SOURCEPATH.arg, "sourcepath",
                 Option.CLASSPATH.arg, "classpath",
-                Option.MODULEPATH.arg, "modulepath",
+                Option.MODULE_PATH.arg, "modulepath",
                 Option.PERMIT_SOURCES_WITHOUT_PACKAGE.arg,
                 Option.PERMIT_UNIDENTIFIED_ARTIFACTS.arg,
                 Option.TR.arg, ".prop=" + CompileJavaPackages.class.getName(),