Merge
authorjjg
Fri, 20 Jan 2017 18:24:50 -0800
changeset 43278 e9f4ee9bfd86
parent 43277 edf2836a33f7 (current diff)
parent 43276 0f8dd574fa0a (diff)
child 43279 9afb33b0a3ab
Merge
--- a/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 17469f16fbb406ec9f0dd262ce776ab6efbc38f1 jdk-9+150
 37b95df0042ae0687324e1f7dc4a2519e230e704 jdk-9+151
 ab2c8b03c3284fcbdd157551a66f807e3a182d9b jdk-9+152
+d7034ff7f8e257e81c9f95c7785dd4eaaa3c2afc jdk-9+153
--- a/.hgtags-top-repo	Fri Jan 20 18:23:34 2017 -0800
+++ b/.hgtags-top-repo	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 6234069ff9789f7582e1faa32cb6283cbd1a5a2d jdk-9+150
 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151
 ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152
+816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153
--- a/corba/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/corba/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 9205e980062a5c4530b51021c6e274025f4ccbdf jdk-9+150
 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151
 ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152
+68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153
--- a/hotspot/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/hotspot/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -555,3 +555,4 @@
 98fe046473c90204cbc9b34c512b9fc10dfb8479 jdk-9+150
 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151
 31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152
+217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153
--- a/jaxp/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/jaxp/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 f85154af719f99a3b4d81b67a8b4c18a650d10f9 jdk-9+150
 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151
 7e3da313b1746578da648155e37dd8526e83153d jdk-9+152
+1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153
--- a/jaxws/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/jaxws/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -398,3 +398,4 @@
 77e4e30d9d111272cd4a45a2203e8f570d40b12e jdk-9+150
 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151
 6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152
+7a532a9a227137155b905341d4b99939db51220e jdk-9+153
--- a/jdk/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/jdk/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 71e198ef3839045e829a879af1d709be16ab0f88 jdk-9+150
 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151
 a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152
+1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153
--- a/langtools/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -395,3 +395,4 @@
 e5a42ddaf633fde14b983f740ae0e7e490741fd1 jdk-9+150
 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151
 5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152
+03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -1045,7 +1045,7 @@
         DO_NOT_RESOLVE_BY_DEFAULT(0x0001),
         WARN_DEPRECATED(0x0002),
         WARN_DEPRECATED_REMOVAL(0x0004),
-        WARN_INCUBATOR(0x0008);
+        WARN_INCUBATING(0x0008);
 
         public static int value(Set<ModuleResolutionFlags> s) {
             int v = 0;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -818,4 +818,12 @@
     public Collection<ModuleSymbol> getAllModules() {
         return modules.values();
     }
+
+    public Iterable<ClassSymbol> getClassesForName(Name candidate) {
+        return classes.getOrDefault(candidate, Collections.emptyMap()).values();
+    }
+
+    public Iterable<PackageSymbol> getPackagesForName(Name candidate) {
+        return packages.getOrDefault(candidate, Collections.emptyMap()).values();
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri Jan 20 18:24:50 2017 -0800
@@ -118,6 +118,8 @@
         Source source = Source.instance(context);
         allowRepeatedAnnos = source.allowRepeatedAnnotations();
         sourceName = source.name;
+
+        blockCount = 1;
     }
 
     /** Semaphore to delay annotation processing */
@@ -144,6 +146,10 @@
     /** are we blocking annotation processing? */
     public boolean annotationsBlocked() {return blockCount > 0; }
 
+    public void enterDone() {
+        unblockAnnotations();
+    }
+
     public List<TypeCompound> fromAnnotations(List<JCAnnotation> annotations) {
         if (annotations.isEmpty()) {
             return List.nil();
@@ -1316,4 +1322,8 @@
                     }
                 };
     }
+
+    public void newRound() {
+        blockCount = 1;
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Jan 20 18:24:50 2017 -0800
@@ -41,6 +41,7 @@
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import javax.lang.model.SourceVersion;
@@ -114,6 +115,7 @@
 import static com.sun.tools.javac.code.Kinds.Kind.ERR;
 import static com.sun.tools.javac.code.Kinds.Kind.MDL;
 import static com.sun.tools.javac.code.Kinds.Kind.MTH;
+import com.sun.tools.javac.code.Symbol.ModuleResolutionFlags;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
 
 /**
@@ -976,7 +978,7 @@
 
         @Override
         public void visitRequires(JCRequires tree) {
-            if (tree.directive != null) {
+            if (tree.directive != null && allModules().contains(tree.directive.module)) {
                 chk.checkDeprecated(tree.moduleName.pos(), msym, tree.directive.module);
                 msym.directives = msym.directives.prepend(tree.directive);
             }
@@ -1090,6 +1092,10 @@
         Predicate<ModuleSymbol> observablePred = sym ->
              (observable == null) ? (moduleFinder.findModule(sym).kind != ERR) : observable.contains(sym);
         Predicate<ModuleSymbol> systemModulePred = sym -> (sym.flags() & Flags.SYSTEM_MODULE) != 0;
+        Predicate<ModuleSymbol> noIncubatorPred = sym -> {
+            sym.complete();
+            return !sym.resolutionFlags.contains(ModuleResolutionFlags.DO_NOT_RESOLVE_BY_DEFAULT);
+        };
         Set<ModuleSymbol> enabledRoot = new LinkedHashSet<>();
 
         if (rootModules.contains(syms.unnamedModule)) {
@@ -1108,7 +1114,7 @@
             }
 
             for (ModuleSymbol sym : new HashSet<>(syms.getAllModules())) {
-                if (systemModulePred.test(sym) && observablePred.test(sym) && jdkModulePred.test(sym)) {
+                if (systemModulePred.test(sym) && observablePred.test(sym) && jdkModulePred.test(sym) && noIncubatorPred.test(sym)) {
                     enabledRoot.add(sym);
                 }
             }
@@ -1128,14 +1134,14 @@
                 Stream<ModuleSymbol> modules;
                 switch (added) {
                     case ALL_SYSTEM:
-                        modules = syms.getAllModules()
-                                      .stream()
-                                      .filter(systemModulePred.and(observablePred));
+                        modules = new HashSet<>(syms.getAllModules())
+                                .stream()
+                                .filter(systemModulePred.and(observablePred).and(noIncubatorPred));
                         break;
                     case ALL_MODULE_PATH:
-                        modules = syms.getAllModules()
-                                      .stream()
-                                      .filter(systemModulePred.negate().and(observablePred));
+                        modules = new HashSet<>(syms.getAllModules())
+                                .stream()
+                                .filter(systemModulePred.negate().and(observablePred));
                         break;
                     default:
                         if (!isValidName(added))
@@ -1155,6 +1161,15 @@
 
         result.add(syms.unnamedModule);
 
+        String incubatingModules = result.stream()
+                .filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
+                .map(msym -> msym.name.toString())
+                .collect(Collectors.joining(","));
+
+        if (!incubatingModules.isEmpty()) {
+            log.warning(Warnings.IncubatingModules(incubatingModules));
+        }
+
         allModules = result;
 
         //add module versions from options, if any:
@@ -1248,7 +1263,6 @@
         msym.requires = msym.requires.appendList(List.from(addReads.getOrDefault(msym, Collections.emptySet())));
 
         List<RequiresDirective> requires = msym.requires;
-        List<RequiresDirective> previous = null;
 
         while (requires.nonEmpty()) {
             if (!allModules().contains(requires.head.module)) {
@@ -1263,13 +1277,7 @@
                 } else {
                     Assert.check((msym.flags() & Flags.AUTOMATIC_MODULE) == 0);
                 }
-                if (previous != null) {
-                    previous.tail = requires.tail;
-                } else {
-                    msym.requires.tail = requires.tail;
-                }
-            } else {
-                previous = requires;
+                msym.requires = List.filter(msym.requires, requires.head);
             }
             requires = requires.tail;
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -41,6 +41,7 @@
 import com.sun.tools.javac.comp.Resolve.ReferenceLookupResult.StaticKind;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
@@ -61,12 +62,12 @@
 import java.util.Set;
 import java.util.function.BiFunction;
 import java.util.function.BiPredicate;
+import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
 import javax.lang.model.element.ElementVisitor;
 
-import com.sun.tools.javac.code.Directive.ExportsDirective;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
 import static com.sun.tools.javac.code.Flags.STATIC;
@@ -74,9 +75,8 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
-import com.sun.tools.javac.resources.CompilerProperties.Errors;
-import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import static com.sun.tools.javac.util.Iterators.createCompoundIterator;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
  *
@@ -1970,7 +1970,7 @@
      *  @param env       The current environment.
      *  @param name      The fully qualified name of the class to be loaded.
      */
-    Symbol loadClass(Env<AttrContext> env, Name name) {
+    Symbol loadClass(Env<AttrContext> env, Name name, RecoveryLoadClass recoveryLoadClass) {
         try {
             ClassSymbol c = finder.loadClass(env.toplevel.modle, name);
             return isAccessible(env, c) ? c : new AccessError(env, null, c);
@@ -1987,40 +1987,60 @@
         }
     }
 
-    public static interface RecoveryLoadClass {
+    public interface RecoveryLoadClass {
         Symbol loadClass(Env<AttrContext> env, Name name);
     }
 
-    private RecoveryLoadClass recoveryLoadClass = new RecoveryLoadClass() {
-        @Override
-        public Symbol loadClass(Env<AttrContext> env, Name name) {
-            if (allowModules) {
-                Scope importScope = env.toplevel.namedImportScope;
-                Symbol existing = importScope.findFirst(Convert.shortName(name),
-                                                        sym -> sym.kind == TYP && sym.flatName() == name);
-
-                if (existing != null) {
-                    return new InvisibleSymbolError(env, true, existing);
-                }
-
-                return lookupInvisibleSymbol(env, name, syms::getClass, (ms, n) -> {
+    private final RecoveryLoadClass noRecovery = (env, name) -> null;
+
+    private final RecoveryLoadClass doRecoveryLoadClass = new RecoveryLoadClass() {
+        @Override public Symbol loadClass(Env<AttrContext> env, Name name) {
+            List<Name> candidates = Convert.classCandidates(name);
+            return lookupInvisibleSymbol(env, name,
+                                         n -> () -> createCompoundIterator(candidates,
+                                                                           c -> syms.getClassesForName(c)
+                                                                                    .iterator()),
+                                         (ms, n) -> {
+                for (Name candidate : candidates) {
                     try {
-                        return finder.loadClass(ms, n);
+                        return finder.loadClass(ms, candidate);
                     } catch (CompletionFailure cf) {
                         //ignore
-                        return null;
                     }
-                }, sym -> sym.kind == Kind.TYP, false, typeNotFound);
-            }
-            return null;
+                }
+                return null;
+            }, sym -> sym.kind == Kind.TYP, false, typeNotFound);
         }
     };
 
-    public RecoveryLoadClass setRecoveryLoadClass(RecoveryLoadClass recovery) {
-        RecoveryLoadClass prev = recoveryLoadClass;
-        recoveryLoadClass = recovery;
-        return prev;
-    }
+    private final RecoveryLoadClass namedImportScopeRecovery = (env, name) -> {
+        Scope importScope = env.toplevel.namedImportScope;
+        Symbol existing = importScope.findFirst(Convert.shortName(name),
+                                                sym -> sym.kind == TYP && sym.flatName() == name);
+
+        if (existing != null) {
+            return new InvisibleSymbolError(env, true, existing);
+        }
+        return null;
+    };
+
+    private final RecoveryLoadClass starImportScopeRecovery = (env, name) -> {
+        Scope importScope = env.toplevel.starImportScope;
+        Symbol existing = importScope.findFirst(Convert.shortName(name),
+                                                sym -> sym.kind == TYP && sym.flatName() == name);
+
+        if (existing != null) {
+            try {
+                existing = finder.loadClass(existing.packge().modle, name);
+
+                return new InvisibleSymbolError(env, true, existing);
+            } catch (CompletionFailure cf) {
+                //ignore
+            }
+        }
+
+        return null;
+    };
 
     Symbol lookupPackage(Env<AttrContext> env, Name name) {
         PackageSymbol pack = syms.lookupPackage(env.toplevel.modle, name);
@@ -2034,7 +2054,7 @@
                                                           .stream()
                                                           .anyMatch(p -> p.fullname.startsWith(nameAndDot));
 
-                return lookupInvisibleSymbol(env, name, syms::getPackage, syms::enterPackage, sym -> {
+                return lookupInvisibleSymbol(env, name, syms::getPackagesForName, syms::enterPackage, sym -> {
                     sym.complete();
                     return sym.exists();
                 }, prefixOfKnown, pack);
@@ -2059,42 +2079,44 @@
         return TreeInfo.fullName(((JCFieldAccess) qualid).selected) == name;
     }
 
-    private Symbol lookupInvisibleSymbol(Env<AttrContext> env,
-                                         Name name,
-                                         BiFunction<ModuleSymbol, Name, Symbol> get,
-                                         BiFunction<ModuleSymbol, Name, Symbol> load,
-                                         Predicate<Symbol> validate,
-                                         boolean suppressError,
-                                         Symbol defaultResult) {
+    private <S extends Symbol> Symbol lookupInvisibleSymbol(Env<AttrContext> env,
+                                                            Name name,
+                                                            Function<Name, Iterable<S>> get,
+                                                            BiFunction<ModuleSymbol, Name, S> load,
+                                                            Predicate<S> validate,
+                                                            boolean suppressError,
+                                                            Symbol defaultResult) {
         //even if a class/package cannot be found in the current module and among packages in modules
         //it depends on that are exported for any or this module, the class/package may exist internally
         //in some of these modules, or may exist in a module on which this module does not depend.
         //Provide better diagnostic in such cases by looking for the class in any module:
+        Iterable<? extends S> candidates = get.apply(name);
+
+        for (S sym : candidates) {
+            if (validate.test(sym))
+                return new InvisibleSymbolError(env, suppressError, sym);
+        }
+
         Set<ModuleSymbol> recoverableModules = new HashSet<>(syms.getAllModules());
 
         recoverableModules.remove(env.toplevel.modle);
 
         for (ModuleSymbol ms : recoverableModules) {
-            Symbol sym = get.apply(ms, name);
-
             //avoid overly eager completing classes from source-based modules, as those
             //may not be completable with the current compiler settings:
-            if (sym == null && (ms.sourceLocation == null)) {
+            if (ms.sourceLocation == null) {
                 if (ms.classLocation == null) {
                     ms = moduleFinder.findModule(ms);
                 }
 
                 if (ms.kind != ERR) {
-                    sym = load.apply(ms, name);
+                    S sym = load.apply(ms, name);
+
+                    if (sym != null && validate.test(sym)) {
+                        return new InvisibleSymbolError(env, suppressError, sym);
+                    }
                 }
             }
-
-            if (sym == null)
-                continue;
-
-            if (validate.test(sym)) {
-                return new InvisibleSymbolError(env, suppressError, sym);
-            }
         }
 
         return defaultResult;
@@ -2186,10 +2208,10 @@
      *  @param scope     The scope in which to look for the type.
      *  @param name      The type's name.
      */
-    Symbol findGlobalType(Env<AttrContext> env, Scope scope, Name name) {
+    Symbol findGlobalType(Env<AttrContext> env, Scope scope, Name name, RecoveryLoadClass recoveryLoadClass) {
         Symbol bestSoFar = typeNotFound;
         for (Symbol s : scope.getSymbolsByName(name)) {
-            Symbol sym = loadClass(env, s.flatName());
+            Symbol sym = loadClass(env, s.flatName(), recoveryLoadClass);
             if (bestSoFar.kind == TYP && sym.kind == TYP &&
                 bestSoFar != sym)
                 return new AmbiguityError(bestSoFar, sym);
@@ -2260,15 +2282,15 @@
         }
 
         if (!env.tree.hasTag(IMPORT)) {
-            sym = findGlobalType(env, env.toplevel.namedImportScope, name);
+            sym = findGlobalType(env, env.toplevel.namedImportScope, name, namedImportScopeRecovery);
             if (sym.exists()) return sym;
             else bestSoFar = bestOf(bestSoFar, sym);
 
-            sym = findGlobalType(env, env.toplevel.packge.members(), name);
+            sym = findGlobalType(env, env.toplevel.packge.members(), name, noRecovery);
             if (sym.exists()) return sym;
             else bestSoFar = bestOf(bestSoFar, sym);
 
-            sym = findGlobalType(env, env.toplevel.starImportScope, name);
+            sym = findGlobalType(env, env.toplevel.starImportScope, name, starImportScopeRecovery);
             if (sym.exists()) return sym;
             else bestSoFar = bestOf(bestSoFar, sym);
         }
@@ -2315,7 +2337,11 @@
         Name fullname = TypeSymbol.formFullName(name, pck);
         Symbol bestSoFar = typeNotFound;
         if (kind.contains(KindSelector.TYP)) {
-            Symbol sym = loadClass(env, fullname);
+            RecoveryLoadClass recoveryLoadClass =
+                    allowModules && !kind.contains(KindSelector.PCK) &&
+                    !pck.exists() && !env.info.isSpeculative ?
+                        doRecoveryLoadClass : noRecovery;
+            Symbol sym = loadClass(env, fullname, recoveryLoadClass);
             if (sym.exists()) {
                 // don't allow programs to use flatnames
                 if (name == sym.name) return sym;
@@ -4136,11 +4162,21 @@
 
             JCDiagnostic details = inaccessiblePackageReason(env, sym.packge());
 
-            if (pos.getTree() != null && pos.getTree().hasTag(SELECT) && sym.owner.kind == PCK) {
-                pos = ((JCFieldAccess) pos.getTree()).selected.pos();
-
-                return diags.create(dkind, log.currentSource(),
-                        pos, "package.not.visible", sym.packge(), details);
+            if (pos.getTree() != null) {
+                Symbol o = sym;
+                JCTree tree = pos.getTree();
+
+                while (o.kind != PCK && tree.hasTag(SELECT)) {
+                    o = o.owner;
+                    tree = ((JCFieldAccess) tree).selected;
+                }
+
+                if (o.kind == PCK) {
+                    pos = tree.pos();
+
+                    return diags.create(dkind, log.currentSource(),
+                            pos, "package.not.visible", o, details);
+                }
             }
 
             return diags.create(dkind, log.currentSource(),
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Fri Jan 20 18:24:50 2017 -0800
@@ -588,7 +588,9 @@
         checkOptionAllowed(t.compareTo(Target.JDK1_9) >= 0,
                 option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
                 Option.MODULE_SOURCE_PATH, Option.UPGRADE_MODULE_PATH,
-                Option.SYSTEM, Option.MODULE_PATH, Option.ADD_MODULES, Option.LIMIT_MODULES,
+                Option.SYSTEM, Option.MODULE_PATH, Option.ADD_MODULES,
+                Option.ADD_EXPORTS, Option.ADD_OPENS, Option.ADD_READS,
+                Option.LIMIT_MODULES,
                 Option.PATCH_MODULE);
 
         if (fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -363,7 +363,7 @@
      **/
     protected boolean implicitSourceFilesRead;
 
-    protected boolean enterDone;
+    private boolean enterDone;
 
     protected CompileStates compileStates;
 
@@ -1042,7 +1042,7 @@
     public List<JCCompilationUnit> initModules(List<JCCompilationUnit> roots) {
         modules.initModules(roots);
         if (roots.isEmpty()) {
-            enterDone = true;
+            enterDone();
         }
         return roots;
     }
@@ -1063,7 +1063,7 @@
 
         enter.main(roots);
 
-        enterDone = true;
+        enterDone();
 
         if (!taskListener.isEmpty()) {
             for (JCCompilationUnit unit: roots) {
@@ -1725,6 +1725,11 @@
         }
     }
 
+    public void enterDone() {
+        enterDone = true;
+        annotate.enterDone();
+    }
+
     public boolean isEnterDone() {
         return enterDone;
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Fri Jan 20 18:24:50 2017 -0800
@@ -184,39 +184,34 @@
             return nameToSymbol(syms.noModule, nameStr, clazz);
         }
 
-        RecoveryLoadClass prevRecoveryLoadClass = resolve.setRecoveryLoadClass((env, name) -> null);
-        try {
-            Set<S> found = new LinkedHashSet<>();
+        Set<S> found = new LinkedHashSet<>();
+
+        for (ModuleSymbol msym : modules.allModules()) {
+            S sym = nameToSymbol(msym, nameStr, clazz);
 
-            for (ModuleSymbol msym : modules.allModules()) {
-                S sym = nameToSymbol(msym, nameStr, clazz);
-
-                if (sym != null) {
-                    if (!allowModules || clazz == ClassSymbol.class || !sym.members().isEmpty()) {
-                        //do not add packages without members:
-                        found.add(sym);
-                    }
+            if (sym != null) {
+                if (!allowModules || clazz == ClassSymbol.class || !sym.members().isEmpty()) {
+                    //do not add packages without members:
+                    found.add(sym);
                 }
             }
+        }
 
-            if (found.size() == 1) {
-                return found.iterator().next();
-            } else if (found.size() > 1) {
-                //more than one element found, produce a note:
-                if (alreadyWarnedDuplicates.add(methodName + ":" + nameStr)) {
-                    String moduleNames = found.stream()
-                                              .map(s -> s.packge().modle)
-                                              .map(m -> m.toString())
-                                              .collect(Collectors.joining(", "));
-                    log.note(Notes.MultipleElements(methodName, nameStr, moduleNames));
-                }
-                return null;
-            } else {
-                //not found, or more than one element found:
-                return null;
+        if (found.size() == 1) {
+            return found.iterator().next();
+        } else if (found.size() > 1) {
+            //more than one element found, produce a note:
+            if (alreadyWarnedDuplicates.add(methodName + ":" + nameStr)) {
+                String moduleNames = found.stream()
+                                          .map(s -> s.packge().modle)
+                                          .map(m -> m.toString())
+                                          .collect(Collectors.joining(", "));
+                log.note(Notes.MultipleElements(methodName, nameStr, moduleNames));
             }
-        } finally {
-            resolve.setRecoveryLoadClass(prevRecoveryLoadClass);
+            return null;
+        } else {
+            //not found, or more than one element found:
+            return null;
         }
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -92,6 +92,7 @@
 
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.comp.Annotate;
 import static com.sun.tools.javac.comp.CompileStates.CompileState;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 
@@ -123,6 +124,7 @@
     private final JavaCompiler compiler;
     private final Modules modules;
     private final Types types;
+    private final Annotate annotate;
 
     /**
      * Holds relevant state history of which processors have been
@@ -219,6 +221,7 @@
         typeUtils = JavacTypes.instance(context);
         modules = Modules.instance(context);
         types = Types.instance(context);
+        annotate = Annotate.instance(context);
         processorOptions = initProcessorOptions();
         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
         messages = JavacMessages.instance(context);
@@ -1256,6 +1259,7 @@
             compiler.newRound();
             modules.newRound();
             types.newRound();
+            annotate.newRound();
 
             boolean foundError = false;
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 20 18:24:50 2017 -0800
@@ -1535,6 +1535,10 @@
 compiler.warn.poor.choice.for.module.name=\
     module name {0} should avoid terminal digits
 
+# 0: string
+compiler.warn.incubating.modules=\
+    using incubating module(s): {0}
+
 # 0: symbol, 1: symbol
 compiler.warn.has.been.deprecated=\
     {0} in {1} has been deprecated
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Convert.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Convert.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -335,4 +335,16 @@
         }
         return names;
     }
+
+    public static List<Name> classCandidates(Name name) {
+        List<Name> names = List.nil();
+        String nameStr = name.toString();
+        int index = -1;
+        while ((index = nameStr.indexOf('.', index + 1)) > 0) {
+            String pack = nameStr.substring(0, index + 1);
+            String clz = nameStr.substring(index + 1).replace('.', '$');
+            names = names.prepend(name.table.names.fromString(pack + clz));
+        }
+        return names.reverse();
+    }
 }
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocEnter.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocEnter.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.main.JavaCompiler;
 
 /**
  *  Javadoc's own enter phase does a few things above and beyond that
@@ -65,16 +66,19 @@
         super(context);
         messager = Messager.instance0(context);
         docenv = DocEnv.instance(context);
+        compiler = JavaCompiler.instance(context);
     }
 
     final Messager messager;
     final DocEnv docenv;
+    final JavaCompiler compiler;
 
     @Override
     public void main(List<JCCompilationUnit> trees) {
         // count all Enter errors as warnings.
         int nerrors = messager.nerrors;
         super.main(trees);
+        compiler.enterDone();
         messager.nwarnings += (messager.nerrors - nerrors);
         messager.nerrors = nerrors;
     }
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTool.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTool.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -219,7 +219,6 @@
             // Enter symbols for all files
             docenv.notice("main.Building_tree");
             javadocEnter.main(classTrees.toList().appendList(packageTrees.toList()));
-            enterDone = true;
         } catch (Abort ex) {}
 
         if (messager.nerrors() != 0)
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.main.JavaCompiler;
 
 /**
  *  Javadoc's own enter phase does a few things above and beyond that
@@ -64,16 +65,19 @@
         super(context);
         messager = Messager.instance0(context);
         toolEnv = ToolEnvironment.instance(context);
+        compiler = JavaCompiler.instance(context);
     }
 
     final Messager messager;
     final ToolEnvironment toolEnv;
+    final JavaCompiler compiler;
 
     @Override
     public void main(List<JCCompilationUnit> trees) {
         // count all Enter errors as warnings.
         int nerrors = messager.nerrors;
         super.main(trees);
+        compiler.enterDone();
         messager.nwarnings += (messager.nerrors - nerrors);
         messager.nerrors = nerrors;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -202,7 +202,6 @@
             javadocEnter.main(classTrees.toList().appendList(packageTrees));
             etable.setClassDeclList(listClasses(classTrees.toList()));
 
-            enterDone = true;
             etable.analyze();
         } catch (CompletionFailure cf) {
             throw new ToolException(ABNORMAL, cf.getMessage(), cf);
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleResolution_attribute.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleResolution_attribute.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -50,7 +50,7 @@
     public ModuleResolution_attribute(ConstantPool constant_pool,
                               int resolution_flags)
             throws ConstantPoolException {
-        this(constant_pool.getUTF8Index(Attribute.ModulePackages),
+        this(constant_pool.getUTF8Index(Attribute.ModuleResolution),
              resolution_flags);
     }
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jan 20 18:24:50 2017 -0800
@@ -987,7 +987,7 @@
                     break;
                 }
                 String trimmed = trimEnd(raw);
-                if (!trimmed.isEmpty()) {
+                if (!trimmed.isEmpty() || !incomplete.isEmpty()) {
                     String line = incomplete + trimmed;
 
                     // No commands in the middle of unprocessed source
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jan 20 18:24:50 2017 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -496,6 +496,35 @@
     }
 
     @Test
+    public void testBlankLinesInSnippetContinuation() {
+        test(Locale.ROOT, false, new String[]{"--no-startup"}, "",
+                a -> assertCommand(a, "class C {",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "  int x;",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "}",
+                        "|  created class C"),
+                a -> assertCommand(a, "/list",
+                        "\n" +
+                        "   1 : class C {\n" +
+                        "       \n" +
+                        "       \n" +
+                        "         int x;\n" +
+                        "       \n" +
+                        "       \n" +
+                        "       }")
+        );
+    }
+
+    @Test
     public void testCompoundStart() {
         test(new String[]{"--startup", "DEFAULT", "--startup", "PRINTING"},
                 (a) -> assertCommand(a, "printf(\"%4.2f\", Math.PI)",
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Fri Jan 20 18:24:50 2017 -0800
@@ -103,6 +103,7 @@
 compiler.warn.big.major.version                         # ClassReader
 compiler.warn.future.attr                               # ClassReader
 compiler.warn.illegal.char.for.encoding
+compiler.warn.incubating.modules                        # requires adjusted classfile
 compiler.warn.invalid.archive.file
 compiler.warn.override.bridge
 compiler.warn.position.overflow                         # CRTable: caused by files with long lines >= 1024 chars
--- a/langtools/test/tools/javac/lib/combo/ReusableContext.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/lib/combo/ReusableContext.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -38,6 +38,7 @@
 import com.sun.tools.javac.code.Type.ClassType;
 import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.Annotate;
 import com.sun.tools.javac.comp.Check;
 import com.sun.tools.javac.comp.CompileStates;
 import com.sun.tools.javac.comp.Enter;
@@ -95,6 +96,7 @@
             Types.instance(this).newRound();
             Check.instance(this).newRound();
             Modules.instance(this).newRound();
+            Annotate.instance(this).newRound();
             CompileStates.instance(this).clear();
             MultiTaskListener.instance(this).clear();
 
--- a/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -23,11 +23,12 @@
 
 /*
  * @test
- * @bug 8169197 8172668
+ * @bug 8169197 8172668 8173117
  * @summary Check convenient errors are produced for inaccessible classes.
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.util
  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
  * @run main ConvenientAccessErrorsTest
  */
@@ -37,6 +38,10 @@
 import java.util.Arrays;
 import java.util.List;
 
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Convert;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
 import toolbox.JarTask;
 import toolbox.JavacTask;
 import toolbox.Task;
@@ -79,6 +84,37 @@
     }
 
     @Test
+    public void testNoDepNested(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; }",
+                          "package api; public class Api { public static class Nested {} }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { }",
+                          "package test; public class Test { api.Api.Nested nested; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
     public void testNotExported(Path base) throws Exception {
         Path src = base.resolve("src");
         Path src_m1 = src.resolve("m1x");
@@ -390,8 +426,7 @@
 
         List<String> expected = Arrays.asList(
                 "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)",
-                "Test.java:1:49: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.not.exported: api, m1x)",
-                "2 errors");
+                "1 error");
 
         if (!expected.equals(log))
             throw new Exception("expected output not found; actual: " + log);
@@ -593,4 +628,80 @@
             throw new Exception("expected output not found; actual: " + log);
     }
 
+    @Test
+    public void testInaccessibleInSourceModuleViaBinaryModule(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "@Deprecated module m1x { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires transitive m1x; }");
+        Path src_m3 = src.resolve("m3x");
+        tb.writeJavaFiles(src_m3,
+                          "module m3x { requires transitive m2x; exports api; }",
+                          "package api; class Api { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        new JavacTask(tb)
+            .options("-XDrawDiagnostics",
+                     "--module-source-path", src.toString())
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(classes.resolve("m2x")); //force completion from source if needed
+        Files.delete(classes.resolve("m2x"));
+
+        tb.cleanDirectory(src_m3); //binary only module
+        Files.delete(src_m3);
+
+        //m4x does not depend on m1x/m2x/m3x, so cannot access api.Api
+        //but the recovery search should not complete m2x, as that would cause a deprecation warning:
+        Path src_m4 = src.resolve("m4x");
+        tb.writeJavaFiles(src_m4,
+                          "module m4x { }",
+                          "package m4x; public class Test extends api.Api { }");
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString(),
+                         "--module-path", classes.toString(),
+                         "-Xlint:deprecation")
+                .outdir(classes)
+                .files(findJavaFiles(src_m4))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:40: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m4x, api, m3x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testConvertNameCandidates(Path base) throws Exception {
+        Context ctx = new Context();
+        Names names = Names.instance(ctx);
+        Name name = names.fromString("com.sun.tools.javac.Attr.BreakAttr");
+
+        com.sun.tools.javac.util.List<String> actual =
+                Convert.classCandidates(name).map(n -> n.toString());
+        List<String> expected = Arrays.asList(
+                "com.sun$tools$javac$Attr$BreakAttr",
+                "com.sun.tools$javac$Attr$BreakAttr",
+                "com.sun.tools.javac$Attr$BreakAttr",
+                "com.sun.tools.javac.Attr$BreakAttr",
+                "com.sun.tools.javac.Attr.BreakAttr"
+        );
+
+        if (!expected.equals(actual)) {
+            throw new Exception("Expected names not generated: " + actual);
+        }
+    }
 }
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -23,13 +23,14 @@
 
 /*
  * @test
- * @bug 8154283 8167320
+ * @bug 8154283 8167320 8171098 8172809 8173117
  * @summary tests for multi-module mode compilation
  * @library /tools/lib
  * @modules
  *      jdk.compiler/com.sun.tools.javac.api
  *      jdk.compiler/com.sun.tools.javac.code
  *      jdk.compiler/com.sun.tools.javac.main
+ *      jdk.compiler/com.sun.tools.javac.util
  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
  * @run main EdgeCases
  */
@@ -44,7 +45,16 @@
 import java.util.Objects;
 import java.util.Set;
 
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedOptions;
+import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.ModuleElement.RequiresDirective;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
@@ -484,4 +494,164 @@
             throw new AssertionError("Unexpected output: " + log);
         }
     }
+
+    @Test
+    public void testInvisibleClassVisiblePackageClash(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }",
+                          "package m1x;\n" +
+                          "import m1x.a.*; public class Test { A a; }\n",
+                          "package m1x.a;\n" +
+                          "public class A { }\n");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { }",
+                          "package m1x;\n" +
+                          "public class a { public static class A { } }\n");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        new JavacTask(tb)
+            .options("--module-source-path", src.toString(),
+                     "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll();
+    }
+
+    @Test
+    public void testStripUnknownRequired(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { }");
+        Path src_m3 = src.resolve("m3x");
+        tb.writeJavaFiles(src_m3,
+                          "module m3x { }");
+        Path src_m4 = src.resolve("m4x");
+        tb.writeJavaFiles(src_m4,
+                          "module m4x { }");
+        Path src_test = src.resolve("test");
+        tb.writeJavaFiles(src_test,
+                          "module test { requires m1x; requires m2x; requires java.base; requires m3x; requires m4x; }");
+        Path src_compile = src.resolve("compile");
+        tb.writeJavaFiles(src_compile,
+                          "module compile { exports p to test; }",
+                          "package p; public class Test { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-processor", ListRequires.class.getName(),
+                         "--module-source-path", src.toString(),
+                         "--limit-modules", "compile",
+                         "-XDaccessInternalAPI=true")
+                .outdir(classes)
+                .files(findJavaFiles(src_compile))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.STDOUT);
+
+        List<String> expected = Arrays.asList(
+                "from directives:",
+                "java.base",
+                "from requires:",
+                "java.base"
+        );
+        if (!Objects.equals(log, expected))
+            throw new AssertionError("Unexpected output: " + log);
+    }
+
+    @SupportedAnnotationTypes("*")
+    @SupportedOptions("expectedEnclosedElements")
+    public static final class ListRequires extends AbstractProcessor {
+
+        private int round;
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (round++ == 0) {
+                ModuleElement compileE = processingEnv.getElementUtils().getModuleElement("compile");
+                ModuleElement testE = ElementFilter.exportsIn(compileE.getDirectives()).get(0).getTargetModules().get(0);
+
+                System.out.println("from directives:");
+                for (RequiresDirective rd : ElementFilter.requiresIn(testE.getDirectives())) {
+                    System.out.println(rd.getDependency().getSimpleName());
+                }
+
+                System.out.println("from requires:");
+                for (RequiresDirective rd : ((ModuleSymbol) testE).requires) {
+                    System.out.println(rd.getDependency().getSimpleName());
+                }
+            }
+
+            return false;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+    }
+
+    @Test
+    public void testOnDemandCompletionModuleInfoJava(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "@Deprecated module m1x { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }");
+        Path src_m3 = src.resolve("m3x");
+        tb.writeJavaFiles(src_m3,
+                          "module m3x { requires m2x; requires m1x; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log;
+        List<String> expected;
+
+        log = new JavacTask(tb)
+                .options("--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src_m1))
+                .run()
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("");
+
+        if (!expected.equals(log)) {
+            throw new IllegalStateException(log.toString());
+        }
+
+        log = new JavacTask(tb)
+                .options("--module-source-path", src.toString(),
+                         "-XDrawDiagnostics",
+                         "-Xlint:deprecation")
+                .outdir(classes)
+                .files(findJavaFiles(src_m3))
+                .run()
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "module-info.java:1:23: compiler.warn.has.been.deprecated.module: m1x",
+                "module-info.java:1:37: compiler.warn.has.been.deprecated.module: m1x",
+                "2 warnings"
+        );
+
+        if (!expected.equals(log)) {
+            throw new IllegalStateException(log.toString());
+        }
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/IncubatingTest.java	Fri Jan 20 18:24:50 2017 -0800
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2015, 2017, 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 8171177
+ * @summary Verify that ModuleResolution attribute flags are honored.
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jdeps/com.sun.tools.classfile
+ *          jdk.jdeps/com.sun.tools.javap
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask ModuleTestBase
+ * @run main IncubatingTest
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Attributes;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ClassWriter;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info;
+import com.sun.tools.classfile.ConstantPool.CPInfo;
+import com.sun.tools.classfile.ModuleResolution_attribute;
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.Task.Expect;
+
+public class IncubatingTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new IncubatingTest().runTests();
+    }
+
+    @Test
+    public void testDoNotResolve(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "module jdk.i { exports api; }",
+                          "package api; public class Api { }");
+        Path classes = base.resolve("classes");
+        Files.deleteIfExists(classes);
+        Path iClasses = classes.resolve("jdk.i");
+        tb.createDirectories(iClasses);
+
+        new JavacTask(tb)
+                .outdir(iClasses)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+
+        copyJavaBase(classes);
+
+        Path jdkIModuleInfo = iClasses.resolve("module-info.class");
+        addModuleResolutionAttribute(jdkIModuleInfo, ModuleResolution_attribute.DO_NOT_RESOLVE_BY_DEFAULT);
+
+        Path testSrc = base.resolve("test-src");
+        tb.writeJavaFiles(testSrc,
+                          "class T { api.Api api; }");
+        Path testClasses = base.resolve("test-classes");
+        tb.createDirectories(testClasses);
+
+        List<String> log;
+        List<String> expected;
+
+        log = new JavacTask(tb)
+                .options("--system", "none",
+                         "--upgrade-module-path", classes.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(testClasses)
+                .files(findJavaFiles(testSrc))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)",
+                "1 error"
+        );
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+
+        log = new JavacTask(tb)
+                .options("--system", "none",
+                         "--upgrade-module-path", classes.toString(),
+                         "--add-modules", "ALL-SYSTEM",
+                         "-XDrawDiagnostics")
+                .outdir(testClasses)
+                .files(findJavaFiles(testSrc))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)",
+                "1 error"
+        );
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+
+        new JavacTask(tb)
+                .options("--system", "none",
+                         "--upgrade-module-path", classes.toString(),
+                         "--add-modules", "jdk.i")
+                .outdir(testClasses)
+                .files(findJavaFiles(testSrc))
+                .run()
+                .writeAll();
+
+        Path testModuleSrc = base.resolve("test-module-src");
+        tb.writeJavaFiles(testModuleSrc,
+                          "module test { requires jdk.i; }", //explicit requires of an incubating module
+                          "class T { api.Api api; }");
+        Path testModuleClasses = base.resolve("test-module-classes");
+        tb.createDirectories(testModuleClasses);
+
+        new JavacTask(tb)
+                .options("--system", "none",
+                         "--upgrade-module-path", classes.toString())
+                .outdir(testModuleClasses)
+                .files(findJavaFiles(testModuleSrc))
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testIncubating(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "module jdk.i { exports api; }",
+                          "package api; public class Api { }");
+        Path classes = base.resolve("classes");
+        Files.deleteIfExists(classes);
+        Path iClasses = classes.resolve("jdk.i");
+        tb.createDirectories(iClasses);
+
+        new JavacTask(tb)
+                .outdir(iClasses)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+
+        Path jdkIModuleInfo = iClasses.resolve("module-info.class");
+        addModuleResolutionAttribute(jdkIModuleInfo, ModuleResolution_attribute.WARN_INCUBATING);
+
+        Path testSrc = base.resolve("test-src");
+        tb.writeJavaFiles(testSrc,
+                          "class T { api.Api api; }");
+        Path testClasses = base.resolve("test-classes");
+        tb.createDirectories(testClasses);
+
+        List<String> log;
+        List<String> expected;
+
+        log = new JavacTask(tb)
+                .options("--module-path", classes.toString(),
+                         "--add-modules", "jdk.i",
+                         "-XDrawDiagnostics",
+                         "-Werror")
+                .outdir(testClasses)
+                .files(findJavaFiles(testSrc))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "- compiler.warn.incubating.modules: jdk.i",
+                "- compiler.err.warnings.and.werror",
+                "1 error",
+                "1 warning"
+        );
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+
+        Path testModuleSrc = base.resolve("test-module-src");
+        tb.writeJavaFiles(testModuleSrc,
+                          "module test { requires jdk.i; }", //explicit requires of an incubating module
+                          "class T { api.Api api; }");
+        Path testModuleClasses = base.resolve("test-module-classes");
+        tb.createDirectories(testModuleClasses);
+
+        log = new JavacTask(tb)
+                .options("--module-path", classes.toString(),
+                         "-XDrawDiagnostics",
+                         "-Werror")
+                .outdir(testModuleClasses)
+                .files(findJavaFiles(testModuleSrc))
+                .run(Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "- compiler.warn.incubating.modules: jdk.i",
+                "- compiler.err.warnings.and.werror",
+                "1 error",
+                "1 warning"
+        );
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    private void copyJavaBase(Path targetDir) throws IOException {
+        FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
+        Path javaBase = jrt.getPath("modules", "java.base");
+
+        if (!Files.exists(javaBase)) {
+            throw new AssertionError("No java.base?");
+        }
+
+        Path javaBaseClasses = targetDir.resolve("java.base");
+
+        for (Path clazz : tb.findFiles("class", javaBase)) {
+            Path target = javaBaseClasses.resolve(javaBase.relativize(clazz).toString());
+            Files.createDirectories(target.getParent());
+            Files.copy(clazz, target);
+        }
+    }
+
+    private void addModuleResolutionAttribute(Path classfile, int resolution_flags) throws Exception {
+        ClassFile cf = ClassFile.read(classfile);
+        Attributes attrs = cf.attributes;
+        List<CPInfo> cpData = new ArrayList<>();
+        cpData.add(null);
+        for (CPInfo info : cf.constant_pool.entries()) {
+            cpData.add(info);
+            if (info.size() == 2)
+                cpData.add(null);
+        }
+        cpData.add(new CONSTANT_Utf8_info(Attribute.ModuleResolution));
+        ConstantPool newCP = new ConstantPool(cpData.toArray(new CPInfo[0]));
+        ModuleResolution_attribute res = new ModuleResolution_attribute(newCP, resolution_flags);
+        Map<String, Attribute> newAttributeMap = new HashMap<>(attrs.map);
+        newAttributeMap.put(Attribute.ModuleResolution, res);
+        Attributes newAttrs = new Attributes(newAttributeMap);
+        ClassFile newCF = new ClassFile(cf.magic,
+                                        cf.minor_version,
+                                        cf.major_version,
+                                        newCP,
+                                        cf.access_flags,
+                                        cf.this_class,
+                                        cf.super_class,
+                                        cf.interfaces,
+                                        cf.fields,
+                                        cf.methods,
+                                        newAttrs);
+        try (OutputStream out = Files.newOutputStream(classfile)) {
+            new ClassWriter().write(newCF, out);
+        }
+    }
+}
--- a/langtools/test/tools/javac/modules/PackageMultipleModules.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -70,9 +70,10 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("A.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m1x, test, m2x)",
-                                              "B.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m2x, test, m1x)",
-                                              "2 errors");
+        List<String> expected = Arrays.asList(
+                "A.java:1:26: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.package, test, null)",
+                "B.java:1:26: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.package, test, null)",
+                "2 errors");
         if (!log.equals(expected))
             throw new Exception("expected output not found");
     }
--- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Fri Jan 20 18:23:34 2017 -0800
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Fri Jan 20 18:24:50 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, 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
@@ -88,6 +88,8 @@
                 Path path = fm.asPath(file);
                 int moduleIndex = path.getNameCount() - type.split("\\Q.\\E").length - 1;
                 String moduleName = path.getName(moduleIndex).toString();
+                if (moduleName.startsWith("jdk.incubator.")) //incubator modules not in module graph by default
+                    continue;
                 try {
                     ModuleElement me = elements.getModuleElement(moduleName);
                     me.getClass();
--- a/nashorn/.hgtags	Fri Jan 20 18:23:34 2017 -0800
+++ b/nashorn/.hgtags	Fri Jan 20 18:24:50 2017 -0800
@@ -386,3 +386,4 @@
 ace1d994bca775d6545a4c874ae73d1dfc9ec18b jdk-9+150
 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151
 ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152
+19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153