Merge
authorduke
Wed, 05 Jul 2017 23:09:40 +0200
changeset 44507 c61cc8a34456
parent 44506 18569c523d38 (diff)
parent 44502 fb08f550b0c7 (current diff)
child 44508 b3c5addc14c1
Merge
common/bin/shell-tracer.sh
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml
jdk/src/java.base/share/classes/java/lang/StackFramePermission.java
jdk/src/java.base/share/classes/jdk/internal/loader/ResourceHelper.java
--- a/langtools/.hgtags	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -405,3 +405,6 @@
 39449d2a6398fee779630f041c55c0466f5fd2c0 jdk-9+159
 0f4fef68d2d84ad78b3aaf6eab2c07873aedf971 jdk-9+160
 2340259b31554a3761e9909953c8ab8ef124ac07 jdk-9+161
+440c45c2e8cee78f6883fa6f2505a781505f323c jdk-9+162
+24582dd2649a155876de89273975ebe1adb5f18c jdk-9+163
+c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164
--- a/langtools/make/CompileInterim.gmk	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/CompileInterim.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 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
@@ -47,7 +47,8 @@
           $$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)), \
       EXCLUDES := sun com/sun/tools/jdeps com/sun/tools/javap \
           com/sun/tools/jdeprscan, \
-      EXCLUDE_FILES := module-info.java JavacToolProvider.java JavadocToolProvider.java, \
+      EXCLUDE_FILES := module-info.java JavacToolProvider.java \
+	  JavadocToolProvider.java Standard.java, \
       COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
       BIN := $(BUILDTOOLS_OUTPUTDIR)/override_modules/$(strip $1), \
       ADD_JAVAC_FLAGS := -Xbootclasspath/p:$$(call PathList, \
--- a/langtools/make/build.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/build.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -56,7 +56,7 @@
 tool.javap.main.class=com.sun.tools.javap.Main
 tool.javah.main.class=com.sun.tools.javah.Main
 tool.sjavac.main.class=com.sun.tools.sjavac.Main
-tool.jshell.main.class=jdk.internal.jshell.tool.JShellTool
+tool.jshell.main.class=jdk.internal.jshell.tool.JShellToolProvider
 
 #test configuration:
 jtreg.tests=
--- a/langtools/make/build.xml	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/build.xml	Wed Jul 05 23:09:40 2017 +0200
@@ -89,16 +89,22 @@
     </pathconvert>
 
     <pathconvert property="xpatch.rest" pathsep=" --patch-module=">
-        <regexpmapper from="/([^$/]+)$"
-                      to='\1="${build.modules}/\1"'
-                      handledirsep="yes"/>
+        <scriptmapper language="javascript">
+            fs = project.getProperty("file.separator");
+            path = project.getProperty("build.modules");
+            mod = source.substr(source.lastIndexOf(fs)+1);
+            self.addMappedName(mod + "=\"" + path + fs + mod + "\"");
+        </scriptmapper>
         <dirset dir="${src.dir}" includes="*.*"/>
     </pathconvert>
 
     <pathconvert property="xpatch.noquotes.rest" pathsep=" --patch-module=">
-        <regexpmapper from="/([^$/]+)$"
-                      to="\1=${build.modules}/\1"
-                      handledirsep="yes"/>
+        <scriptmapper language="javascript">
+            fs = project.getProperty("file.separator");
+            path = project.getProperty("build.modules");
+            mod = source.substr(source.lastIndexOf(fs)+1);
+            self.addMappedName(mod + "=" + path + fs + mod);
+        </scriptmapper>
         <dirset dir="${src.dir}" includes="*.*"/>
     </pathconvert>
 
@@ -341,7 +347,7 @@
             <attribute name="agentvm" default="true"/>
             <attribute name="verbose" default="${default.jtreg.verbose}"/>
             <attribute name="options" default="${other.jtreg.options}"/>
-            <attribute name="keywords" default="-keywords:!ignore"/>
+            <attribute name="ignore" default="-keywords:!ignore -exclude:${test.dir}/ProblemList.txt"/>
             <attribute name="jpda.jvmargs" default=""/>
             <attribute name="extra.jvmargs" default=""/>
             <attribute name="build.modules" default="${build.modules}"/>
@@ -360,7 +366,7 @@
                     failonerror="false" resultproperty="jtreg.@{name}.result"
                     vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.noquotes.cmd}">
                     <arg value="-debug:@{jpda.jvmargs}"/>
-                    <arg line="@{keywords}"/>
+                    <arg line="@{ignore}"/>
                     <arg line="@{options}"/>
                     <arg line="@{tests}"/>
                 </jtreg>
--- a/langtools/make/intellij/runConfigurations/javadoc.xml	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/intellij/runConfigurations/javadoc.xml	Wed Jul 05 23:09:40 2017 +0200
@@ -1,8 +1,8 @@
 <component name="ProjectRunConfigurationManager">
   <configuration default="false" name="javadoc" type="Application" factoryName="Application">
     <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
-    <option name="VM_PARAMETERS" value='@XPATCH@' />
+    <option name="MAIN_CLASS_NAME" value="jdk.javadoc.internal.tool.Main" />
+    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED' />
     <option name="PROGRAM_PARAMETERS" value="" />
     <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
     <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/intellij/runConfigurations/jshell.xml	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/intellij/runConfigurations/jshell.xml	Wed Jul 05 23:09:40 2017 +0200
@@ -1,7 +1,7 @@
 <component name="ProjectRunConfigurationManager">
   <configuration default="false" name="jshell" type="Application" factoryName="Application">
     <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellTool" />
+    <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellToolProvider" />
     <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED' />
     <option name="PROGRAM_PARAMETERS" value="" />
     <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
--- a/langtools/make/intellij/src/idea/LangtoolsIdeaAntLogger.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/make/intellij/src/idea/LangtoolsIdeaAntLogger.java	Wed Jul 05 23:09:40 2017 +0200
@@ -263,6 +263,7 @@
                 project.addBuildListener(this);
             }
         }
+        logger.setMessageOutputLevel(3);
         tasks.push(Task.ROOT);
     }
 
--- a/langtools/src/java.compiler/share/classes/javax/annotation/processing/Filer.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Filer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,7 @@
 import javax.tools.JavaFileManager;
 import javax.tools.*;
 import javax.lang.model.element.Element;
+import javax.lang.model.util.Elements;
 import java.io.IOException;
 
 /**
@@ -157,6 +158,12 @@
      * example, to create a source file for type {@code a.B} in module
      * {@code foo}, use a {@code name} argument of {@code "foo/a.B"}.
      *
+     * <p>If no explicit module prefix is given and modules are supported
+     * in the environment, a suitable module is inferred. If a suitable
+     * module cannot be inferred {@link FilerException} is thrown.
+     * An implementation may use information about the configuration of
+     * the annotation processing tool as part of the inference.
+     *
      * <p>Creating a source file in or for an unnamed package in a named
      * module is <em>not</em> supported.
      *
@@ -176,6 +183,17 @@
      * ProcessingEnvironment#getSourceVersion source version} being used
      * for this run.
      *
+     * @implNote In the reference implementation, if the annotation
+     * processing tool is processing a single module <i>M</i>,
+     * then <i>M</i> is used as the module for files created without
+     * an explicit module prefix. If the tool is processing multiple
+     * modules, and {@link
+     * Elements#getPackageElement(java.lang.CharSequence)
+     * Elements.getPackageElement(package-of(name))}
+     * returns a package, the module that owns the returned package is used
+     * as the target module. A separate option may be used to provide the target
+     * module if it cannot be determined using the above rules.
+     *
      * @param name  canonical (fully qualified) name of the principal type
      *          being declared in this file or a package name followed by
      *          {@code ".package-info"} for a package information file
@@ -184,8 +202,11 @@
      * {@code null}
      * @return a {@code JavaFileObject} to write the new source file
      * @throws FilerException if the same pathname has already been
-     * created, the same type has already been created, or the name is
-     * otherwise not valid for the entity requested to being created
+     * created, the same type has already been created, the name is
+     * otherwise not valid for the entity requested to being created,
+     * if the target module cannot be determined, if the target
+     * module is not writable, or a module is specified when the environment
+     * doesn't support modules.
      * @throws IOException if the file cannot be created
      * @jls 7.3 Compilation Units
      */
@@ -213,6 +234,12 @@
      * example, to create a class file for type {@code a.B} in module
      * {@code foo}, use a {@code name} argument of {@code "foo/a.B"}.
      *
+     * <p>If no explicit module prefix is given and modules are supported
+     * in the environment, a suitable module is inferred. If a suitable
+     * module cannot be inferred {@link FilerException} is thrown.
+     * An implementation may use information about the configuration of
+     * the annotation processing tool as part of the inference.
+     *
      * <p>Creating a class file in or for an unnamed package in a named
      * module is <em>not</em> supported.
      *
@@ -221,6 +248,17 @@
      * ProcessingEnvironment#getSourceVersion source version} being
      * used for this run.
      *
+     * @implNote In the reference implementation, if the annotation
+     * processing tool is processing a single module <i>M</i>,
+     * then <i>M</i> is used as the module for files created without
+     * an explicit module prefix. If the tool is processing multiple
+     * modules, and {@link
+     * Elements#getPackageElement(java.lang.CharSequence)
+     * Elements.getPackageElement(package-of(name))}
+     * returns a package, the module that owns the returned package is used
+     * as the target module. A separate option may be used to provide the target
+     * module if it cannot be determined using the above rules.
+     *
      * @param name binary name of the type being written or a package name followed by
      *          {@code ".package-info"} for a package information file
      * @param originatingElements type or package or module elements causally
@@ -228,8 +266,10 @@
      * {@code null}
      * @return a {@code JavaFileObject} to write the new class file
      * @throws FilerException if the same pathname has already been
-     * created, the same type has already been created, or the name is
-     * not valid for a type
+     * created, the same type has already been created, the name is
+     * not valid for a type, if the target module cannot be determined,
+     * if the target module is not writable, or a module is specified when
+     * the environment doesn't support modules.
      * @throws IOException if the file cannot be created
      */
     JavaFileObject createClassFile(CharSequence name,
@@ -255,11 +295,37 @@
      * does not contain a "{@code /}" character, the entire argument
      * is interpreted as a package name.
      *
+     * <p>If the given location is neither a {@linkplain
+     * JavaFileManager.Location#isModuleOrientedLocation()
+     * module oriented location}, nor an {@linkplain
+     * JavaFileManager.Location#isOutputLocation()
+     * output location containing multiple modules}, and the explicit
+     * module prefix is given, {@link FilerException} is thrown.
+     *
+     * <p>If the given location is either a module oriented location,
+     * or an output location containing multiple modules, and no explicit
+     * modules prefix is given, a suitable module is
+     * inferred. If a suitable module cannot be inferred {@link
+     * FilerException} is thrown. An implementation may use information
+     * about the configuration of the annotation processing tool
+     * as part of the inference.
+     *
      * <p>Files created via this method are <em>not</em> registered for
      * annotation processing, even if the full pathname of the file
      * would correspond to the full pathname of a new source file
      * or new class file.
      *
+     * @implNote In the reference implementation, if the annotation
+     * processing tool is processing a single module <i>M</i>,
+     * then <i>M</i> is used as the module for files created without
+     * an explicit module prefix. If the tool is processing multiple
+     * modules, and {@link
+     * Elements#getPackageElement(java.lang.CharSequence)
+     * Elements.getPackageElement(package-of(name))}
+     * returns a package, the module that owns the returned package is used
+     * as the target module. A separate option may be used to provide the target
+     * module if it cannot be determined using the above rules.
+     *
      * @param location location of the new file
      * @param moduleAndPkg module and/or package relative to which the file
      *           should be named, or the empty string if none
@@ -270,7 +336,9 @@
      * @return a {@code FileObject} to write the new resource
      * @throws IOException if the file cannot be created
      * @throws FilerException if the same pathname has already been
-     * created
+     * created, if the target module cannot be determined,
+     * or if the target module is not writable, or if an explicit
+     * target module is specified and the location does not support it.
      * @throws IllegalArgumentException for an unsupported location
      * @throws IllegalArgumentException if {@code moduleAndPkg} is ill-formed
      * @throws IllegalArgumentException if {@code relativeName} is not relative
@@ -294,13 +362,41 @@
      * does not contain a "{@code /}" character, the entire argument
      * is interpreted as a package name.
      *
+     * <p>If the given location is neither a {@linkplain
+     * JavaFileManager.Location#isModuleOrientedLocation()
+     * module oriented location}, nor an {@linkplain
+     * JavaFileManager.Location#isOutputLocation()
+     * output location containing multiple modules}, and the explicit
+     * module prefix is given, {@link FilerException} is thrown.
+     *
+     * <p>If the given location is either a module oriented location,
+     * or an output location containing multiple modules, and no explicit
+     * modules prefix is given, a suitable module is
+     * inferred. If a suitable module cannot be inferred {@link
+     * FilerException} is thrown. An implementation may use information
+     * about the configuration of the annotation processing tool
+     * as part of the inference.
+     *
+     * @implNote In the reference implementation, if the annotation
+     * processing tool is processing a single module <i>M</i>,
+     * then <i>M</i> is used as the module for files read without
+     * an explicit module prefix. If the tool is processing multiple
+     * modules, and {@link
+     * Elements#getPackageElement(java.lang.CharSequence)
+     * Elements.getPackageElement(package-of(name))}
+     * returns a package, the module that owns the returned package is used
+     * as the source module. A separate option may be used to provide the target
+     * module if it cannot be determined using the above rules.
+     *
      * @param location location of the file
      * @param moduleAndPkg module and/or package relative to which the file
      *          should be searched for, or the empty string if none
      * @param relativeName final pathname components of the file
      * @return an object to read the file
      * @throws FilerException if the same pathname has already been
-     * opened for writing
+     * opened for writing, if the source module cannot be determined,
+     * or if the target module is not writable, or if an explicit target
+     * module is specified and the location does not support it.
      * @throws IOException if the file cannot be opened
      * @throws IllegalArgumentException for an unsupported location
      * @throws IllegalArgumentException if {@code moduleAndPkg} is ill-formed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Generated.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javax.annotation.processing;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * The Generated annotation is used to mark source code that has been generated.
+ * It can also be used to differentiate user written code from generated code in
+ * a single file.
+ *
+ * <h3>Examples:</h3>
+ * <pre>
+ *   &#064;Generated("com.example.Generator")
+ * </pre>
+ * <pre>
+ *   &#064;Generated(value="com.example.Generator", date= "2017-07-04T12:08:56.235-0700")
+ * </pre>
+ * <pre>
+ *   &#064;Generated(value="com.example.Generator", date= "2017-07-04T12:08:56.235-0700",
+ *      comments= "comment 1")
+ * </pre>
+ *
+ * @since 9
+ */
+@Documented
+@Retention(SOURCE)
+@Target({PACKAGE, TYPE, METHOD, CONSTRUCTOR, FIELD,
+    LOCAL_VARIABLE, PARAMETER})
+public @interface Generated {
+
+    /**
+     * The value element MUST have the name of the code generator. The
+     * name is the fully qualified name of the code generator.
+     *
+     * @return The name of the code generator
+     */
+    String[] value();
+
+    /**
+     * Date when the source was generated. The date element must follow the ISO
+     * 8601 standard. For example the date element would have the following
+     * value 2017-07-04T12:08:56.235-0700 which represents 2017-07-04 12:08:56
+     * local time in the U.S. Pacific Time time zone.
+     *
+     * @return The date the source was generated
+     */
+    String date() default "";
+
+    /**
+     * A place holder for any comments that the code generator may want to
+     * include in the generated code.
+     *
+     * @return Comments that the code generated included
+     */
+    String comments() default "";
+}
--- a/langtools/src/java.compiler/share/classes/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
   * and define interfaces for tools such as compilers which can be invoked
   * from a program.
   *
+  * @moduleGraph
   * @since 9
   */
 module java.compiler {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -39,6 +39,7 @@
 import javax.tools.JavaFileObject.Kind;
 import javax.tools.StandardLocation;
 
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.Completer;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
@@ -90,7 +91,7 @@
 
     private ModuleNameReader moduleNameReader;
 
-    public ModuleInfoSourceFileCompleter sourceFileCompleter;
+    public ModuleNameFromSourceReader moduleNameFromSourceReader;
 
     /** Get the ModuleFinder instance for this invocation. */
     public static ModuleFinder instance(Context context) {
@@ -190,8 +191,6 @@
         return list;
     }
 
-    private boolean inFindSingleModule;
-
     public ModuleSymbol findSingleModule() {
         try {
             JavaFileObject src_fo = getModuleInfoFromLocation(StandardLocation.SOURCE_PATH, Kind.SOURCE);
@@ -204,44 +203,14 @@
             if (fo == null) {
                 msym = syms.unnamedModule;
             } else {
-                switch (fo.getKind()) {
-                    case SOURCE:
-                        if (!inFindSingleModule) {
-                            try {
-                                inFindSingleModule = true;
-                                // Note: the following will trigger a re-entrant call to Modules.enter
-                                msym = sourceFileCompleter.complete(fo);
-                                msym.module_info.classfile = fo;
-                            } finally {
-                                inFindSingleModule = false;
-                            }
-                        } else {
-                            //the module-info.java does not contain a module declaration,
-                            //avoid infinite recursion:
-                            msym = syms.unnamedModule;
-                        }
-                        break;
-                    case CLASS:
-                        Name name;
-                        try {
-                            name = names.fromString(readModuleName(fo));
-                        } catch (BadClassFile | IOException ex) {
-                            //fillIn will report proper errors:
-                            name = names.error;
-                        }
-                        msym = syms.enterModule(name);
-                        msym.module_info.classfile = fo;
-                        msym.completer = Completer.NULL_COMPLETER;
-                        classFinder.fillIn(msym.module_info);
-                        break;
-                    default:
-                        Assert.error();
-                        msym = syms.unnamedModule;
-                        break;
-                }
+                msym = readModule(fo);
             }
 
-            msym.classLocation = StandardLocation.CLASS_OUTPUT;
+            if (msym.patchLocation == null) {
+                msym.classLocation = StandardLocation.CLASS_OUTPUT;
+            } else {
+                msym.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
+            }
             return msym;
 
         } catch (IOException e) {
@@ -249,6 +218,54 @@
         }
     }
 
+    private ModuleSymbol readModule(JavaFileObject fo) throws IOException {
+        Name name;
+        switch (fo.getKind()) {
+            case SOURCE:
+                name = moduleNameFromSourceReader.readModuleName(fo);
+                if (name == null) {
+                    JCDiagnostic diag =
+                        diags.fragment("file.does.not.contain.module");
+                    ClassSymbol errModuleInfo = syms.defineClass(names.module_info, syms.errModule);
+                    throw new ClassFinder.BadClassFile(errModuleInfo, fo, diag, diags);
+                }
+                break;
+            case CLASS:
+                try {
+                    name = names.fromString(readModuleName(fo));
+                } catch (BadClassFile | IOException ex) {
+                    //fillIn will report proper errors:
+                    name = names.error;
+                }
+                break;
+            default:
+                Assert.error();
+                name = names.error;
+                break;
+        }
+
+        ModuleSymbol msym = syms.enterModule(name);
+        msym.module_info.classfile = fo;
+        if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && name != names.error) {
+            msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, name.toString());
+
+            if (msym.patchLocation != null) {
+                JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
+                patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
+                patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);
+
+                if (patchFO != null) {
+                    msym.module_info.classfile = patchFO;
+                }
+            }
+        }
+
+        msym.completer = Completer.NULL_COMPLETER;
+        classFinder.fillIn(msym.module_info);
+
+        return msym;
+    }
+
     private String readModuleName(JavaFileObject jfo) throws IOException, ModuleNameReader.BadClassFile {
         if (moduleNameReader == null)
             moduleNameReader = new ModuleNameReader();
@@ -256,7 +273,7 @@
     }
 
     private JavaFileObject getModuleInfoFromLocation(Location location, Kind kind) throws IOException {
-        if (!fileManager.hasLocation(location))
+        if (location == null || !fileManager.hasLocation(location))
             return null;
 
         return fileManager.getJavaFileForInput(location,
@@ -285,24 +302,20 @@
                             msym.patchLocation =
                                     fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH,
                                                                      msym.name.toString());
-                            checkModuleInfoOnLocation(msym.patchLocation, Kind.CLASS, Kind.SOURCE);
                             if (msym.patchLocation != null &&
                                 multiModuleMode &&
                                 fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
                                 msym.patchOutputLocation =
                                         fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
                                                                          msym.name.toString());
-                                checkModuleInfoOnLocation(msym.patchOutputLocation, Kind.CLASS);
                             }
                         }
                         if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) {
-                            if (msym.patchLocation == null) {
-                                msym.sourceLocation = l;
-                                if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
-                                    msym.classLocation =
-                                            fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
-                                                                             msym.name.toString());
-                                }
+                            msym.sourceLocation = l;
+                            if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
+                                msym.classLocation =
+                                        fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
+                                                                         msym.name.toString());
                             }
                         } else {
                             msym.classLocation = l;
@@ -332,34 +345,18 @@
         return results.toList();
     }
 
-    private void checkModuleInfoOnLocation(Location location, Kind... kinds) throws IOException {
-        if (location == null)
-            return ;
-
-        for (Kind kind : kinds) {
-            JavaFileObject file = fileManager.getJavaFileForInput(location,
-                                                                  names.module_info.toString(),
-                                                                  kind);
-            if (file != null) {
-                log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(file));
-                return;
-            }
-        }
-    }
-
     private void findModuleInfo(ModuleSymbol msym) {
         try {
-            JavaFileObject src_fo = (msym.sourceLocation == null) ? null
-                    : fileManager.getJavaFileForInput(msym.sourceLocation,
-                            names.module_info.toString(), Kind.SOURCE);
+            JavaFileObject fo;
 
-            JavaFileObject class_fo = (msym.classLocation == null) ? null
-                    : fileManager.getJavaFileForInput(msym.classLocation,
-                            names.module_info.toString(), Kind.CLASS);
+            fo = getModuleInfoFromLocation(msym.patchOutputLocation, Kind.CLASS);
+            fo = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), fo);
+            fo = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), fo);
 
-            JavaFileObject fo = (src_fo == null) ? class_fo :
-                    (class_fo == null) ? src_fo :
-                    classFinder.preferredFileObject(src_fo, class_fo);
+            if (fo == null) {
+                fo = getModuleInfoFromLocation(msym.classLocation, Kind.CLASS);
+                fo = preferredFileObject(getModuleInfoFromLocation(msym.sourceLocation, Kind.SOURCE), fo);
+            }
 
             if (fo == null) {
                 String moduleName = msym.sourceLocation == null && msym.classLocation != null ?
@@ -388,6 +385,12 @@
         }
     }
 
+    private JavaFileObject preferredFileObject(JavaFileObject fo1, JavaFileObject fo2) {
+        if (fo1 == null) return fo2;
+        if (fo2 == null) return fo1;
+        return classFinder.preferredFileObject(fo1, fo2);
+    }
+
     Fragment getDescription(StandardLocation l) {
         switch (l) {
             case MODULE_PATH: return Fragments.LocnModule_path;
@@ -399,8 +402,8 @@
         }
     }
 
-    public interface ModuleInfoSourceFileCompleter {
-        public ModuleSymbol complete(JavaFileObject file);
+    public interface ModuleNameFromSourceReader {
+        public Name readModuleName(JavaFileObject file);
     }
 
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -362,14 +362,9 @@
 
             TreeMapper treeMapper = new TreeMapper(context);
             //TODO: to further refine the analysis, try all rewriting combinations
-            LocalCacheContext localCacheContext = argumentAttr.withLocalCacheContext();
-            try {
-                deferredAttr.attribSpeculative(fakeBlock, env, attr.statInfo, treeMapper,
-                        t -> new AnalyzeDeferredDiagHandler(context));
-            } finally {
-                localCacheContext.leave();
-            }
-
+            deferredAttr.attribSpeculative(fakeBlock, env, attr.statInfo, treeMapper,
+                    t -> new AnalyzeDeferredDiagHandler(context),
+                    argumentAttr.withLocalCacheContext());
             context.treeMap.entrySet().forEach(e -> {
                 context.treesToAnalyzer.get(e.getKey())
                         .process(e.getKey(), e.getValue(), context.errors.nonEmpty());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 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
@@ -260,8 +260,10 @@
     public void visitReference(JCMemberReference tree) {
         //perform arity-based check
         Env<AttrContext> localEnv = env.dup(tree);
-        JCExpression exprTree = (JCExpression)deferredAttr.attribSpeculative(tree.getQualifierExpression(), localEnv,
-                attr.memberReferenceQualifierResult(tree));
+        JCExpression exprTree;
+        exprTree = (JCExpression)deferredAttr.attribSpeculative(tree.getQualifierExpression(), localEnv,
+                attr.memberReferenceQualifierResult(tree),
+                withLocalCacheContext());
         JCMemberReference mref2 = new TreeCopier<Void>(attr.make).copy(tree);
         mref2.expr = exprTree;
         Symbol lhsSym = TreeInfo.symbol(exprTree);
@@ -277,9 +279,9 @@
                 (res.flags() & Flags.VARARGS) != 0 ||
                 (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
                 exprTree.type.isRaw() && !exprTree.type.hasTag(ARRAY))) {
-            tree.overloadKind = JCMemberReference.OverloadKind.OVERLOADED;
+            tree.setOverloadKind(JCMemberReference.OverloadKind.OVERLOADED);
         } else {
-            tree.overloadKind = JCMemberReference.OverloadKind.UNOVERLOADED;
+            tree.setOverloadKind(JCMemberReference.OverloadKind.UNOVERLOADED);
         }
         //return a plain old deferred type for this
         setResult(tree, deferredAttr.new DeferredType(tree, env));
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 05 23:09:40 2017 +0200
@@ -448,13 +448,21 @@
 
         NORMAL,
 
-        NO_TREE_UPDATE {     // Mode signalling 'fake check' - skip tree update
+        /**
+         * Mode signalling 'fake check' - skip tree update. A side-effect of this mode is
+         * that the captured var cache in {@code InferenceContext} will be used in read-only
+         * mode when performing inference checks.
+         */
+        NO_TREE_UPDATE {
             @Override
             public boolean updateTreeType() {
                 return false;
             }
         },
-        NO_INFERENCE_HOOK { // Mode signalling that caller will manage free types in tree decorations.
+        /**
+         * Mode signalling that caller will manage free types in tree decorations.
+         */
+        NO_INFERENCE_HOOK {
             @Override
             public boolean installPostInferenceHook() {
                 return false;
@@ -1517,7 +1525,9 @@
                             isBooleanOrNumeric(env, condTree.falsepart);
                 case APPLY:
                     JCMethodInvocation speculativeMethodTree =
-                            (JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo);
+                            (JCMethodInvocation)deferredAttr.attribSpeculative(
+                                    tree, env, unknownExprInfo,
+                                    argumentAttr.withLocalCacheContext());
                     Symbol msym = TreeInfo.symbol(speculativeMethodTree.meth);
                     Type receiverType = speculativeMethodTree.meth.hasTag(IDENT) ?
                             env.enclClass.type :
@@ -1528,10 +1538,13 @@
                     JCExpression className =
                             removeClassParams.translate(((JCNewClass)tree).clazz);
                     JCExpression speculativeNewClassTree =
-                            (JCExpression)deferredAttr.attribSpeculative(className, env, unknownTypeInfo);
+                            (JCExpression)deferredAttr.attribSpeculative(
+                                    className, env, unknownTypeInfo,
+                                    argumentAttr.withLocalCacheContext());
                     return primitiveOrBoxed(speculativeNewClassTree.type);
                 default:
-                    Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type;
+                    Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo,
+                            argumentAttr.withLocalCacheContext()).type;
                     return primitiveOrBoxed(speculativeType);
             }
         }
@@ -3769,7 +3782,7 @@
                 break;
             case MTH: {
                 owntype = checkMethod(site, sym,
-                        new ResultInfo(resultInfo.pkind, resultInfo.pt.getReturnType(), resultInfo.checkContext),
+                        new ResultInfo(resultInfo.pkind, resultInfo.pt.getReturnType(), resultInfo.checkContext, resultInfo.checkMode),
                         env, TreeInfo.args(env.tree), resultInfo.pt.getParameterTypes(),
                         resultInfo.pt.getTypeArguments());
                 break;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -56,6 +56,9 @@
 import java.util.WeakHashMap;
 import java.util.function.Function;
 
+import com.sun.source.tree.MemberReferenceTree;
+import com.sun.tools.javac.tree.JCTree.JCMemberReference.OverloadKind;
+
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
@@ -148,6 +151,27 @@
                         return super.visitNewClass(node, p);
                     }
                 }
+
+                @Override @DefinedBy(Api.COMPILER_TREE)
+                public JCTree visitMemberReference(MemberReferenceTree node, Void p) {
+                    JCMemberReference t = (JCMemberReference) node;
+                    JCExpression expr = copy(t.expr, p);
+                    List<JCExpression> typeargs = copy(t.typeargs, p);
+                    /** once the value for overloadKind is determined for a copy, it can be safely forwarded to
+                     *  the copied tree, we want to profit from that
+                     */
+                    JCMemberReference result = new JCMemberReference(t.mode, t.name, expr, typeargs) {
+                        @Override
+                        public void setOverloadKind(OverloadKind overloadKind) {
+                            super.setOverloadKind(overloadKind);
+                            if (t.getOverloadKind() == null) {
+                                t.setOverloadKind(overloadKind);
+                            }
+                        }
+                    };
+                    result.pos = t.pos;
+                    return result;
+                }
             };
         deferredCopier = new TypeMapping<Void> () {
                 @Override
@@ -446,11 +470,17 @@
      */
     JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
         return attribSpeculative(tree, env, resultInfo, treeCopier,
-                (newTree)->new DeferredAttrDiagHandler(log, newTree));
+                (newTree)->new DeferredAttrDiagHandler(log, newTree), null);
+    }
+
+    JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo, LocalCacheContext localCache) {
+        return attribSpeculative(tree, env, resultInfo, treeCopier,
+                (newTree)->new DeferredAttrDiagHandler(log, newTree), localCache);
     }
 
     <Z> JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo, TreeCopier<Z> deferredCopier,
-                                 Function<JCTree, DeferredDiagnosticHandler> diagHandlerCreator) {
+                                 Function<JCTree, DeferredDiagnosticHandler> diagHandlerCreator,
+                                 LocalCacheContext localCache) {
         final JCTree newTree = deferredCopier.copy(tree);
         Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared(env.info.scope.owner)));
         speculativeEnv.info.isSpeculative = true;
@@ -461,6 +491,9 @@
         } finally {
             new UnenterScanner(env.toplevel.modle).scan(newTree);
             log.popDiagnosticHandler(deferredDiagnosticHandler);
+            if (localCache != null) {
+                localCache.leave();
+            }
         }
     }
     //where
@@ -847,6 +880,7 @@
 
             @Override
             public void visitReference(JCMemberReference tree) {
+                Assert.checkNonNull(tree.getOverloadKind());
                 Check.CheckContext checkContext = resultInfo.checkContext;
                 Type pt = resultInfo.pt;
                 if (!inferenceContext.inferencevars.contains(pt)) {
@@ -856,8 +890,9 @@
                         checkContext.report(null, ex.getDiagnostic());
                     }
                     Env<AttrContext> localEnv = env.dup(tree);
-                    JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
-                            attr.memberReferenceQualifierResult(tree));
+                    JCExpression exprTree;
+                    exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
+                            attr.memberReferenceQualifierResult(tree), argumentAttr.withLocalCacheContext());
                     ListBuffer<Type> argtypes = new ListBuffer<>();
                     for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
                         argtypes.append(Type.noType);
@@ -1125,7 +1160,7 @@
             Type descType = types.findDescriptorType(pt);
             List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
             if (freeArgVars.nonEmpty() &&
-                    tree.overloadKind == JCMemberReference.OverloadKind.OVERLOADED) {
+                    tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
                 stuckVars.addAll(freeArgVars);
                 depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType()));
             }
@@ -1190,7 +1225,7 @@
         @Override
         public void visitReference(JCMemberReference tree) {
             super.visitReference(tree);
-            if (tree.overloadKind == JCMemberReference.OverloadKind.OVERLOADED) {
+            if (tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
                 stuck = true;
             }
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
 
 import com.sun.tools.javac.code.Type.UndetVar.UndetVarListener;
 import com.sun.tools.javac.code.Types.TypeMapping;
+import com.sun.tools.javac.comp.Attr.CheckMode;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCTypeCast;
 import com.sun.tools.javac.tree.TreeInfo;
@@ -190,28 +191,29 @@
                 doIncorporation(inferenceContext, warn);
                 //we are inside method attribution - just return a partially inferred type
                 return new PartiallyInferredMethodType(mt, inferenceContext, env, warn);
-            } else if (allowGraphInference &&
-                    resultInfo != null &&
-                    !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+            } else if (allowGraphInference && resultInfo != null) {
+
                 //inject return constraints earlier
                 doIncorporation(inferenceContext, warn); //propagation
 
-                boolean shouldPropagate = shouldPropagate(mt.getReturnType(), resultInfo, inferenceContext);
+                if (!warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+                    boolean shouldPropagate = shouldPropagate(mt.getReturnType(), resultInfo, inferenceContext);
 
-                InferenceContext minContext = shouldPropagate ?
-                        inferenceContext.min(roots(mt, deferredAttrContext), true, warn) :
-                        inferenceContext;
+                    InferenceContext minContext = shouldPropagate ?
+                            inferenceContext.min(roots(mt, deferredAttrContext), true, warn) :
+                            inferenceContext;
 
-                Type newRestype = generateReturnConstraints(env.tree, resultInfo,  //B3
-                        mt, minContext);
-                mt = (MethodType)types.createMethodTypeWithReturn(mt, newRestype);
+                    Type newRestype = generateReturnConstraints(env.tree, resultInfo,  //B3
+                            mt, minContext);
+                    mt = (MethodType)types.createMethodTypeWithReturn(mt, newRestype);
 
-                //propagate outwards if needed
-                if (shouldPropagate) {
-                    //propagate inference context outwards and exit
-                    minContext.dupTo(resultInfo.checkContext.inferenceContext());
-                    deferredAttrContext.complete();
-                    return mt;
+                    //propagate outwards if needed
+                    if (shouldPropagate) {
+                        //propagate inference context outwards and exit
+                        minContext.dupTo(resultInfo.checkContext.inferenceContext());
+                        deferredAttrContext.complete();
+                        return mt;
+                    }
                 }
             }
 
@@ -318,7 +320,7 @@
                  */
                 saved_undet = inferenceContext.save();
                 boolean unchecked = warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED);
-                if (allowGraphInference && !unchecked) {
+                if (!unchecked) {
                     boolean shouldPropagate = shouldPropagate(getReturnType(), resultInfo, inferenceContext);
 
                     InferenceContext minContext = shouldPropagate ?
@@ -338,9 +340,13 @@
                 }
                 inferenceContext.solve(noWarnings);
                 Type ret = inferenceContext.asInstType(this).getReturnType();
-                //inline logic from Attr.checkMethod - if unchecked conversion was required, erase
-                //return type _after_ resolution
-                return unchecked ? types.erasure(ret) : ret;
+                if (unchecked) {
+                    //inline logic from Attr.checkMethod - if unchecked conversion was required, erase
+                    //return type _after_ resolution, and check against target
+                    ret = types.erasure(ret);
+                    resultInfo.check(env.tree, ret);
+                }
+                return ret;
             } catch (InferenceException ex) {
                 resultInfo.checkContext.report(null, ex.getDiagnostic());
                 Assert.error(); //cannot get here (the above should throw)
@@ -414,7 +420,7 @@
             }
         } else if (rsInfoInfContext.free(resultInfo.pt)) {
             //propagation - cache captured vars
-            qtype = inferenceContext.asUndetVar(rsInfoInfContext.cachedCapture(tree, from, false));
+            qtype = inferenceContext.asUndetVar(rsInfoInfContext.cachedCapture(tree, from, !resultInfo.checkMode.updateTreeType()));
         }
         Assert.check(allowGraphInference || !rsInfoInfContext.free(to),
                 "legacy inference engine cannot handle constraints on both sides of a subtyping assertion");
@@ -504,7 +510,7 @@
         inferenceContext.solve(List.of(from.qtype), new Warner());
         inferenceContext.notifyChange();
         Type capturedType = resultInfo.checkContext.inferenceContext()
-                .cachedCapture(tree, from.getInst(), false);
+                .cachedCapture(tree, from.getInst(), !resultInfo.checkMode.updateTreeType());
         if (types.isConvertible(capturedType,
                 resultInfo.checkContext.inferenceContext().asUndetVar(to))) {
             //effectively skip additional return-type constraint generation (compatibility)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -89,7 +89,6 @@
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
 import com.sun.tools.javac.tree.JCTree.JCOpens;
-import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
 import com.sun.tools.javac.tree.JCTree.JCProvides;
 import com.sun.tools.javac.tree.JCTree.JCRequires;
 import com.sun.tools.javac.tree.JCTree.JCUses;
@@ -112,6 +111,7 @@
 import static com.sun.tools.javac.code.Flags.ENUM;
 import static com.sun.tools.javac.code.Flags.PUBLIC;
 import static com.sun.tools.javac.code.Flags.UNATTRIBUTED;
+import com.sun.tools.javac.code.Kinds;
 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;
@@ -167,6 +167,8 @@
     private Set<ModuleSymbol> rootModules = null;
     private final Set<ModuleSymbol> warnedMissing = new HashSet<>();
 
+    public PackageNameFinder findPackageInFile;
+
     public static Modules instance(Context context) {
         Modules instance = context.get(Modules.class);
         if (instance == null)
@@ -399,9 +401,18 @@
                         }
                         if (msym.sourceLocation == null) {
                             msym.sourceLocation = msplocn;
+                            if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH)) {
+                                msym.patchLocation = fileManager.getLocationForModule(
+                                        StandardLocation.PATCH_MODULE_PATH, msym.name.toString());
+                            }
                             if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
-                                msym.classLocation = fileManager.getLocationForModule(
+                                Location outputLocn = fileManager.getLocationForModule(
                                         StandardLocation.CLASS_OUTPUT, msym.name.toString());
+                                if (msym.patchLocation == null) {
+                                    msym.classLocation = outputLocn;
+                                } else {
+                                    msym.patchOutputLocation = outputLocn;
+                                }
                             }
                         }
                         tree.modle = msym;
@@ -451,7 +462,6 @@
                                 defaultModule.classLocation = StandardLocation.CLASS_PATH;
                             }
                         } else {
-                            checkSpecifiedModule(trees, moduleOverride, Errors.ModuleInfoWithPatchedModuleClassoutput);
                             checkNoAllModulePath();
                             defaultModule.complete();
                             // Question: why not do completeModule here?
@@ -461,18 +471,30 @@
                         rootModules.add(defaultModule);
                         break;
                     case 1:
-                        checkSpecifiedModule(trees, moduleOverride, Errors.ModuleInfoWithPatchedModuleSourcepath);
                         checkNoAllModulePath();
                         defaultModule = rootModules.iterator().next();
                         defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
-                        defaultModule.classLocation = StandardLocation.CLASS_OUTPUT;
+                        if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH)) {
+                            try {
+                                defaultModule.patchLocation = fileManager.getLocationForModule(
+                                        StandardLocation.PATCH_MODULE_PATH, defaultModule.name.toString());
+                            } catch (IOException ex) {
+                                throw new Error(ex);
+                            }
+                        }
+                        if (defaultModule.patchLocation == null) {
+                            defaultModule.classLocation = StandardLocation.CLASS_OUTPUT;
+                        } else {
+                            defaultModule.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
+                        }
                         break;
                     default:
                         Assert.error("too many modules");
                 }
-            } else if (rootModules.size() == 1 && defaultModule == rootModules.iterator().next()) {
-                defaultModule.complete();
-                defaultModule.completer = sym -> completeModule((ModuleSymbol) sym);
+            } else if (rootModules.size() == 1) {
+                module = rootModules.iterator().next();
+                module.complete();
+                module.completer = sym -> completeModule((ModuleSymbol) sym);
             } else {
                 Assert.check(rootModules.isEmpty());
                 String moduleOverride = singleModuleOverride(trees);
@@ -553,17 +575,6 @@
         return loc;
     }
 
-    private void checkSpecifiedModule(List<JCCompilationUnit> trees, String moduleOverride, JCDiagnostic.Error error) {
-        if (moduleOverride != null) {
-            JavaFileObject prev = log.useSource(trees.head.sourcefile);
-            try {
-                log.error(trees.head.pos(), error);
-            } finally {
-                log.useSource(prev);
-            }
-        }
-    }
-
     private void checkNoAllModulePath() {
         if (addModsOpt != null && Arrays.asList(addModsOpt.split(",")).contains(ALL_MODULE_PATH)) {
             log.error(Errors.AddmodsAllModulePathInvalid);
@@ -694,6 +705,11 @@
         return rootModules.contains(module);
     }
 
+    public Set<ModuleSymbol> getRootModules() {
+        Assert.checkNonNull(rootModules);
+        return rootModules;
+    }
+
     class ModuleVisitor extends JCTree.Visitor {
         private ModuleSymbol sym;
         private final Set<ModuleSymbol> allRequires = new HashSet<>();
@@ -938,7 +954,30 @@
 
         @Override
         public void visitExports(JCExports tree) {
-            if (tree.directive.packge.members().isEmpty()) {
+            Iterable<Symbol> packageContent = tree.directive.packge.members().getSymbols();
+            List<JavaFileObject> filesToCheck = List.nil();
+            boolean packageNotEmpty = false;
+            for (Symbol sym : packageContent) {
+                if (sym.kind != Kinds.Kind.TYP)
+                    continue;
+                ClassSymbol csym = (ClassSymbol) sym;
+                if (sym.completer.isTerminal() ||
+                    csym.classfile.getKind() == Kind.CLASS) {
+                    packageNotEmpty = true;
+                    filesToCheck = List.nil();
+                    break;
+                }
+                if (csym.classfile.getKind() == Kind.SOURCE) {
+                    filesToCheck = filesToCheck.prepend(csym.classfile);
+                }
+            }
+            for (JavaFileObject jfo : filesToCheck) {
+                if (findPackageInFile.findPackageNameOf(jfo) == tree.directive.packge.fullname) {
+                    packageNotEmpty = true;
+                    break;
+                }
+            }
+            if (!packageNotEmpty) {
                 log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
             }
             msym.directives = msym.directives.prepend(tree.directive);
@@ -1658,4 +1697,8 @@
         rootModules = null;
         warnedMissing.clear();
     }
+
+    public interface PackageNameFinder {
+        public Name findPackageNameOf(JavaFileObject jfo);
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 23:09:40 2017 +0200
@@ -334,7 +334,10 @@
                     currModule.complete();
                     PackageSymbol p = c.packge();
                     isAccessible =
-                        (currModule == p.modle) || currModule.visiblePackages.get(p.fullname) == p || p == syms.rootPackage;
+                        currModule == p.modle ||
+                        currModule.visiblePackages.get(p.fullname) == p ||
+                        p == syms.rootPackage ||
+                        (p.modle == syms.unnamedModule && currModule.readModules.contains(p.modle));
                 } else {
                     isAccessible = true;
                 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -186,37 +186,12 @@
                         Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
                 Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
                 Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
-                return ensureReadable(constr.newInstance(urls, thisClassLoader));
+                return constr.newInstance(urls, thisClassLoader);
             } catch (ReflectiveOperationException t) {
                 // ignore errors loading user-provided class loader, fall through
             }
         }
-        return ensureReadable(new URLClassLoader(urls, thisClassLoader));
-    }
-
-    /**
-     * Ensures that the unnamed module of the given classloader is readable to this
-     * module.
-     */
-    private ClassLoader ensureReadable(ClassLoader targetLoader) {
-        try {
-            Method getModuleMethod = Class.class.getMethod("getModule");
-            Object thisModule = getModuleMethod.invoke(this.getClass());
-            Method getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
-            Object targetModule = getUnnamedModuleMethod.invoke(targetLoader);
-
-            Class<?> moduleClass = getModuleMethod.getReturnType();
-            Method addReadsMethod = moduleClass.getMethod("addReads", moduleClass);
-            addReadsMethod.invoke(thisModule, targetModule);
-        } catch (NoSuchMethodException e) {
-            // ignore
-        } catch (IllegalAccessException
-                | IllegalArgumentException
-                | SecurityException
-                | InvocationTargetException e) {
-            throw new Abort(e);
-        }
-        return targetLoader;
+        return new URLClassLoader(urls, thisClassLoader);
     }
 
     public boolean isDefaultBootClassPath() {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,6 +39,7 @@
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Stream;
@@ -283,23 +284,14 @@
     }
 
     /**
-     * Processes strings containing options and operands.
-     * @param args the strings to be processed
-     * @param allowableOpts the set of option declarations that are applicable
-     * @param helper a help for use by Option.process
-     * @param allowOperands whether or not to check for files and classes
-     * @param checkFileManager whether or not to check if the file manager can handle
-     *      options which are not recognized by any of allowableOpts
-     * @return true if all the strings were successfully processed; false otherwise
-     * @throws IllegalArgumentException if a problem occurs and errorMode is set to
-     *      ILLEGAL_ARGUMENT
+     * Handles the {@code --release} option.
+     *
+     * @param additionalOptions a predicate to handle additional options implied by the
+     * {@code --release} option. The predicate should return true if all the additional
+     * options were processed successfully.
+     * @return true if successful, false otherwise
      */
-    private boolean processArgs(Iterable<String> args,
-            Set<Option> allowableOpts, OptionHelper helper,
-            boolean allowOperands, boolean checkFileManager) {
-        if (!doProcessArgs(args, allowableOpts, helper, allowOperands, checkFileManager))
-            return false;
-
+    public boolean handleReleaseOptions(Predicate<Iterable<String>> additionalOptions) {
         String platformString = options.get(Option.RELEASE);
 
         checkOptionAllowed(platformString == null,
@@ -323,7 +315,7 @@
 
             context.put(PlatformDescription.class, platformDescription);
 
-            if (!doProcessArgs(platformDescription.getAdditionalOptions(), allowableOpts, helper, allowOperands, checkFileManager))
+            if (!additionalOptions.test(platformDescription.getAdditionalOptions()))
                 return false;
 
             Collection<Path> platformCP = platformDescription.getPlatformPath();
@@ -348,6 +340,30 @@
             }
         }
 
+        return true;
+    }
+
+    /**
+     * Processes strings containing options and operands.
+     * @param args the strings to be processed
+     * @param allowableOpts the set of option declarations that are applicable
+     * @param helper a help for use by Option.process
+     * @param allowOperands whether or not to check for files and classes
+     * @param checkFileManager whether or not to check if the file manager can handle
+     *      options which are not recognized by any of allowableOpts
+     * @return true if all the strings were successfully processed; false otherwise
+     * @throws IllegalArgumentException if a problem occurs and errorMode is set to
+     *      ILLEGAL_ARGUMENT
+     */
+    private boolean processArgs(Iterable<String> args,
+            Set<Option> allowableOpts, OptionHelper helper,
+            boolean allowOperands, boolean checkFileManager) {
+        if (!doProcessArgs(args, allowableOpts, helper, allowOperands, checkFileManager))
+            return false;
+
+        if (!handleReleaseOptions(extra -> doProcessArgs(extra, allowableOpts, helper, allowOperands, checkFileManager)))
+            return false;
+
         options.notifyListeners();
 
         return true;
@@ -614,6 +630,7 @@
         validateAddModules(sv);
         validateAddReads(sv);
         validateLimitModules(sv);
+        validateDefaultModuleForCreatedFiles(sv);
 
         if (lintOptions && options.isSet(Option.ADD_OPENS)) {
             log.warning(LintCategory.OPTIONS, Warnings.AddopensIgnored);
@@ -751,6 +768,17 @@
         }
     }
 
+    private void validateDefaultModuleForCreatedFiles(SourceVersion sv) {
+        String moduleName = options.get(Option.DEFAULT_MODULE_FOR_CREATED_FILES);
+        if (moduleName != null) {
+            if (!SourceVersion.isName(moduleName, sv)) {
+                // syntactically invalid module name:  e.g. --default-module-for-created-files m!
+                log.error(Errors.BadNameForOption(Option.DEFAULT_MODULE_FOR_CREATED_FILES,
+                                                  moduleName));
+            }
+        }
+    }
+
     /**
      * Returns true if there are no files or classes specified for use.
      * @return true if there are no files or classes specified for use
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 23:09:40 2017 +0200
@@ -69,12 +69,12 @@
 import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.tree.JCTree.Tag;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.Factory;
+import com.sun.tools.javac.util.Log.DiagnosticHandler;
+import com.sun.tools.javac.util.Log.DiscardDiagnosticHandler;
 import com.sun.tools.javac.util.Log.WriterKind;
 
 import static com.sun.tools.javac.code.Kinds.Kind.*;
@@ -89,6 +89,8 @@
 
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
+
 /** This class could be the main entry point for GJC when GJC is used as a
  *  component in a larger software system. It provides operations to
  *  construct a new compiler, and to run a new compiler on a set of source
@@ -340,13 +342,6 @@
     protected final Symbol.Completer sourceCompleter =
             sym -> readSourceFile((ClassSymbol) sym);
 
-    protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
-            fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
-                return tl.defs.nonEmpty() && tl.defs.head.hasTag(Tag.MODULEDEF) ?
-                        ((JCModuleDecl) tl.defs.head).sym.module_info :
-                        syms.defineClass(names.module_info, syms.errModule);
-            }).owner;
-
     /**
      * Command line options.
      */
@@ -417,7 +412,8 @@
         diags = Factory.instance(context);
 
         finder.sourceCompleter = sourceCompleter;
-        moduleFinder.sourceFileCompleter = moduleInfoSourceFileCompleter;
+        modules.findPackageInFile = this::findPackageInFile;
+        moduleFinder.moduleNameFromSourceReader = this::readModuleName;
 
         options = Options.instance(context);
 
@@ -787,19 +783,6 @@
         readSourceFile(null, c);
     }
 
-    private JCTree.JCCompilationUnit parseImplicitFile(JavaFileObject filename) {
-        JavaFileObject prev = log.useSource(filename);
-        try {
-            JCTree.JCCompilationUnit t = parse(filename, filename.getCharContent(false));
-            return t;
-        } catch (IOException e) {
-            log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
-            return make.TopLevel(List.nil());
-        } finally {
-            log.useSource(prev);
-        }
-    }
-
     /** Compile a ClassSymbol from source, optionally using the given compilation unit as
      *  the source tree.
      *  @param tree the compilation unit in which the given ClassSymbol resides,
@@ -810,20 +793,20 @@
         if (completionFailureName == c.fullname) {
             throw new CompletionFailure(c, "user-selected completion failure by class name");
         }
+        JavaFileObject filename = c.classfile;
+        JavaFileObject prev = log.useSource(filename);
 
         if (tree == null) {
-            tree = parseImplicitFile(c.classfile);
+            try {
+                tree = parse(filename, filename.getCharContent(false));
+            } catch (IOException e) {
+                log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
+                tree = make.TopLevel(List.<JCTree>nil());
+            } finally {
+                log.useSource(prev);
+            }
         }
 
-        readSourceFile(tree, c, cut -> c);
-    }
-
-    private ClassSymbol readSourceFile(JCCompilationUnit tree,
-                                       ClassSymbol expectedSymbol,
-                                       Function<JCCompilationUnit, ClassSymbol> symbolGetter)
-                                           throws CompletionFailure {
-        Assert.checkNonNull(tree);
-
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.started(e);
@@ -835,20 +818,18 @@
         // Note that if module resolution failed, we may not even
         // have enough modules available to access java.lang, and
         // so risk getting FatalError("no.java.lang") from MemberEnter.
-        if (!modules.enter(List.of(tree), expectedSymbol)) {
-            throw new CompletionFailure(symbolGetter.apply(tree),
-                                        diags.fragment("cant.resolve.modules"));
+        if (!modules.enter(List.of(tree), c)) {
+            throw new CompletionFailure(c, diags.fragment("cant.resolve.modules"));
         }
 
-        enter.complete(List.of(tree), expectedSymbol);
+        enter.complete(List.of(tree), c);
 
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.finished(e);
         }
 
-        ClassSymbol sym = symbolGetter.apply(tree);
-        if (sym == null || enter.getEnv(sym) == null) {
+        if (enter.getEnv(c) == null) {
             boolean isPkgInfo =
                 tree.sourcefile.isNameCompatible("package-info",
                                                  JavaFileObject.Kind.SOURCE);
@@ -859,26 +840,24 @@
                 if (enter.getEnv(tree.modle) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.module");
-                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
+                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
                 }
             } else if (isPkgInfo) {
                 if (enter.getEnv(tree.packge) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.package",
-                                                 sym.location());
-                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
+                                                 c.location());
+                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
                 }
             } else {
                 JCDiagnostic diag =
                         diagFactory.fragment("file.doesnt.contain.class",
-                                            sym.getQualifiedName());
-                throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
+                                            c.getQualifiedName());
+                throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
             }
         }
 
         implicitSourceFilesRead = true;
-
-        return sym;
     }
 
     /** Track when the JavaCompiler has been used to compile something. */
@@ -1751,6 +1730,32 @@
         return enterDone;
     }
 
+    private Name readModuleName(JavaFileObject fo) {
+        return parseAndGetName(fo, t -> {
+            JCModuleDecl md = t.getModuleDecl();
+
+            return md != null ? TreeInfo.fullName(md.getName()) : null;
+        });
+    }
+
+    private Name findPackageInFile(JavaFileObject fo) {
+        return parseAndGetName(fo, t -> t.getPackage() != null ?
+                                        TreeInfo.fullName(t.getPackage().getPackageName()) : null);
+    }
+
+    private Name parseAndGetName(JavaFileObject fo,
+                                 Function<JCTree.JCCompilationUnit, Name> tree2Name) {
+        DiagnosticHandler dh = new DiscardDiagnosticHandler(log);
+        try {
+            JCTree.JCCompilationUnit t = parse(fo, fo.getCharContent(false));
+            return tree2Name.apply(t);
+        } catch (IOException e) {
+            return null;
+        } finally {
+            log.popDiagnosticHandler(dh);
+        }
+    }
+
     /** Close the compiler, flushing the logs
      */
     public void close() {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 23:09:40 2017 +0200
@@ -399,6 +399,30 @@
         }
     },
 
+    DEFAULT_MODULE_FOR_CREATED_FILES("--default-module-for-created-files",
+                                     "opt.arg.default.module.for.created.files",
+                                     "opt.default.module.for.created.files", EXTENDED, BASIC) {
+        @Override
+        public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
+            String prev = helper.get(DEFAULT_MODULE_FOR_CREATED_FILES);
+            if (prev != null) {
+                throw helper.newInvalidValueException("err.option.too.many",
+                                                      DEFAULT_MODULE_FOR_CREATED_FILES.primaryName);
+            } else if (arg.isEmpty()) {
+                throw helper.newInvalidValueException("err.no.value.for.option", option);
+            } else if (getPattern().matcher(arg).matches()) {
+                helper.put(DEFAULT_MODULE_FOR_CREATED_FILES.primaryName, arg);
+            } else {
+                throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
+            }
+        }
+
+        @Override
+        public Pattern getPattern() {
+            return Pattern.compile("[^,].*");
+        }
+    },
+
     X("--help-extra -X", "opt.X", STANDARD, INFO) {
         @Override
         public void process(OptionHelper helper, String option) throws InvalidValueException {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -60,6 +60,8 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
+import com.sun.tools.javac.main.Option;
 
 /**
  * The FilerImplementation class must maintain a number of
@@ -384,6 +386,8 @@
 
     private final Set<String> initialClassNames;
 
+    private final String defaultTargetModule;
+
     JavacFiler(Context context) {
         this.context = context;
         fileManager = context.get(JavaFileManager.class);
@@ -408,6 +412,10 @@
         initialClassNames  = new LinkedHashSet<>();
 
         lint = (Lint.instance(context)).isEnabled(PROCESSING);
+
+        Options options = Options.instance(context);
+
+        defaultTargetModule = options.get(Option.DEFAULT_MODULE_FOR_CREATED_FILES);
     }
 
     @Override @DefinedBy(Api.ANNOTATION_PROCESSING)
@@ -427,29 +435,42 @@
     private Pair<ModuleSymbol, String> checkOrInferModule(CharSequence moduleAndPkg) throws FilerException {
         String moduleAndPkgString = moduleAndPkg.toString();
         int slash = moduleAndPkgString.indexOf('/');
-
-        if (slash != (-1)) {
-            //module name specified:
-            String module = moduleAndPkgString.substring(0, slash);
+        String module;
+        String pkg;
 
-            ModuleSymbol explicitModule = syms.getModule(names.fromString(module));
+        if (slash == (-1)) {
+            //module name not specified:
+            int lastDot = moduleAndPkgString.lastIndexOf('.');
+            String pack = lastDot != (-1) ? moduleAndPkgString.substring(0, lastDot) : "";
+            ModuleSymbol msym = inferModule(pack);
 
-            if (explicitModule == null) {
-                throw new FilerException("Module: " + module + " does not exist.");
+            if (msym != null) {
+                return Pair.of(msym, moduleAndPkgString);
+            }
+
+            if (defaultTargetModule == null) {
+                throw new FilerException("Cannot determine target module.");
             }
 
-            if (!modules.isRootModule(explicitModule)) {
-                throw new FilerException("Cannot write to the given module!");
-            }
-
-            return Pair.of(explicitModule, moduleAndPkgString.substring(slash + 1));
+            module = defaultTargetModule;
+            pkg = moduleAndPkgString;
         } else {
-            if (modules.multiModuleMode) {
-                throw new FilerException("No module to write to specified!");
-            }
+            //module name specified:
+            module = moduleAndPkgString.substring(0, slash);
+            pkg = moduleAndPkgString.substring(slash + 1);
+        }
+
+        ModuleSymbol explicitModule = syms.getModule(names.fromString(module));
 
-            return Pair.of(modules.getDefaultModule(), moduleAndPkgString);
+        if (explicitModule == null) {
+            throw new FilerException("Module: " + module + " does not exist.");
         }
+
+        if (!modules.isRootModule(explicitModule)) {
+            throw new FilerException("Cannot write to the given module.");
+        }
+
+        return Pair.of(explicitModule, pkg);
     }
 
     private JavaFileObject createSourceOrClassFile(ModuleSymbol mod, boolean isSourceFile, String name) throws IOException {
@@ -495,17 +516,13 @@
                                      CharSequence moduleAndPkg,
                                      CharSequence relativeName,
                                      Element... originatingElements) throws IOException {
-        Pair<ModuleSymbol, String> moduleAndPackage = checkOrInferModule(moduleAndPkg);
-        ModuleSymbol msym = moduleAndPackage.fst;
-        String pkg = moduleAndPackage.snd;
+        Tuple3<Location, ModuleSymbol, String> locationModuleAndPackage = checkOrInferModule(location, moduleAndPkg, true);
+        location = locationModuleAndPackage.a;
+        ModuleSymbol msym = locationModuleAndPackage.b;
+        String pkg = locationModuleAndPackage.c;
 
         locationCheck(location);
 
-        if (modules.multiModuleMode) {
-            Assert.checkNonNull(msym);
-            location = this.fileManager.getLocationForModule(location, msym.name.toString());
-        }
-
         String strPkg = pkg.toString();
         if (strPkg.length() > 0)
             checkName(strPkg);
@@ -534,14 +551,9 @@
     public FileObject getResource(JavaFileManager.Location location,
                                   CharSequence moduleAndPkg,
                                   CharSequence relativeName) throws IOException {
-        Pair<ModuleSymbol, String> moduleAndPackage = checkOrInferModule(moduleAndPkg);
-        ModuleSymbol msym = moduleAndPackage.fst;
-        String pkg = moduleAndPackage.snd;
-
-        if (modules.multiModuleMode) {
-            Assert.checkNonNull(msym);
-            location = this.fileManager.getLocationForModule(location, msym.name.toString());
-        }
+        Tuple3<Location, ModuleSymbol, String> locationModuleAndPackage = checkOrInferModule(location, moduleAndPkg, false);
+        location = locationModuleAndPackage.a;
+        String pkg = locationModuleAndPackage.c;
 
         if (pkg.length() > 0)
             checkName(pkg);
@@ -578,6 +590,99 @@
         return new FilerInputFileObject(fileObject);
     }
 
+    private Tuple3<JavaFileManager.Location, ModuleSymbol, String> checkOrInferModule(JavaFileManager.Location location,
+                                                           CharSequence moduleAndPkg,
+                                                           boolean write) throws IOException {
+        String moduleAndPkgString = moduleAndPkg.toString();
+        int slash = moduleAndPkgString.indexOf('/');
+        boolean multiModuleLocation = location.isModuleOrientedLocation() ||
+                                      (modules.multiModuleMode && location.isOutputLocation());
+        String module;
+        String pkg;
+
+        if (slash == (-1)) {
+            //module name not specified:
+            if (!multiModuleLocation) {
+                //package oriented location:
+                return new Tuple3<>(location, modules.getDefaultModule(), moduleAndPkgString);
+            }
+
+            if (location.isOutputLocation()) {
+                ModuleSymbol msym = inferModule(moduleAndPkgString);
+
+                if (msym != null) {
+                    Location moduleLoc =
+                            fileManager.getLocationForModule(location, msym.name.toString());
+                    return new Tuple3<>(moduleLoc, msym, moduleAndPkgString);
+                }
+            }
+
+            if (defaultTargetModule == null) {
+                throw new FilerException("No module specified and the location is either " +
+                                         "a module-oriented location, or a multi-module " +
+                                         "output location.");
+            }
+
+            module = defaultTargetModule;
+            pkg = moduleAndPkgString;
+        } else {
+            //module name specified:
+            module = moduleAndPkgString.substring(0, slash);
+            pkg = moduleAndPkgString.substring(slash + 1);
+        }
+
+        if (multiModuleLocation) {
+            ModuleSymbol explicitModule = syms.getModule(names.fromString(module));
+
+            if (explicitModule == null) {
+                throw new FilerException("Module: " + module + " does not exist.");
+            }
+
+            if (write && !modules.isRootModule(explicitModule)) {
+                throw new FilerException("Cannot write to the given module.");
+            }
+
+            Location moduleLoc = fileManager.getLocationForModule(location, module);
+
+            return new Tuple3<>(moduleLoc, explicitModule, pkg);
+        } else {
+            throw new FilerException("Module specified but the location is neither " +
+                                     "a module-oriented location, nor a multi-module " +
+                                     "output location.");
+        }
+    }
+
+    static final class Tuple3<A, B, C> {
+        final A a;
+        final B b;
+        final C c;
+
+        public Tuple3(A a, B b, C c) {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+    }
+
+    private ModuleSymbol inferModule(String pkg) {
+        if (modules.getDefaultModule() == syms.noModule)
+            return modules.getDefaultModule();
+
+        Set<ModuleSymbol> rootModules = modules.getRootModules();
+
+        if (rootModules.size() == 1) {
+            return rootModules.iterator().next();
+        }
+
+        PackageSymbol pack = elementUtils.getPackageElement(pkg);
+
+        if (pack != null && pack.modle != syms.unnamedModule) {
+            return pack.modle;
+        }
+
+        return null;
+    }
+
     private void checkName(String name) throws FilerException {
         checkName(name, false);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1059,8 +1059,10 @@
             roots = prev.roots.appendList(parsedFiles);
 
             // Check for errors after parsing
-            if (unrecoverableError())
+            if (unrecoverableError()) {
+                compiler.initModules(List.nil());
                 return;
+            }
 
             roots = compiler.initModules(roots);
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -2961,12 +2961,6 @@
 compiler.err.module.decl.sb.in.module-info.java=\
     module declarations should be in a file named module-info.java
 
-compiler.err.module-info.with.patched.module.sourcepath=\
-    compiling a module patch with module-info on sourcepath
-
-compiler.err.module-info.with.patched.module.classoutput=\
-    compiling a module patch with module-info on class output
-
 # 0: set of string
 compiler.err.too.many.patched.modules=\
     too many patched modules ({0}), use --module-source-path
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -131,6 +131,8 @@
     "name args"
 javac.opt.arg.multi-release=\
     <release>
+javac.opt.arg.default.module.for.created.files=\
+    <module-name>
 
 ## extended options
 
@@ -323,6 +325,8 @@
     <version>
 javac.opt.inherit_runtime_environment=\
     Inherit module system configuration options from the runtime environment.
+javac.opt.default.module.for.created.files=\
+    Fallback target module for files created by annotation processors, if none specified or inferred.
 
 ## errors
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -2133,7 +2133,7 @@
         public Type varargsElement;
         public PolyKind refPolyKind;
         public boolean ownerAccessible;
-        public OverloadKind overloadKind;
+        private OverloadKind overloadKind;
         public Type referentType;
 
         public enum OverloadKind {
@@ -2174,7 +2174,7 @@
             }
         }
 
-        protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
+        public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
             this.mode = mode;
             this.name = name;
             this.expr = expr;
@@ -2205,6 +2205,20 @@
         public boolean hasKind(ReferenceKind kind) {
             return this.kind == kind;
         }
+
+        /**
+         * @return the overloadKind
+         */
+        public OverloadKind getOverloadKind() {
+            return overloadKind;
+        }
+
+        /**
+         * @param overloadKind the overloadKind to set
+         */
+        public void setOverloadKind(OverloadKind overloadKind) {
+            this.overloadKind = overloadKind;
+        }
     }
 
     /**
--- a/langtools/src/jdk.compiler/share/classes/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  *  {@link javax.tools.ToolProvider#getSystemJavaCompiler system Java compiler}
  *  and its command line equivalent, <em>javac</em>, as well as <em>javah</em>.
  *
+ *  @moduleGraph
  *  @since 9
  */
 module jdk.compiler {
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -33,7 +33,7 @@
  * @deprecated The doclet has been superseded by its replacement,
  * {@code jdk.javadoc.doclets.StandardDoclet}.
  */
-@Deprecated
+@Deprecated(forRemoval=true, since="9")
 public class Standard {
 
     public static int optionLength(String option) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Taglet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Taglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,8 @@
 import java.util.List;
 import java.util.Set;
 
+import javax.lang.model.element.Element;
+
 import com.sun.source.doctree.DocTree;
 
 /**
@@ -65,18 +67,34 @@
     String getName();
 
     /**
+     * Initializes this taglet with the given doclet environment and doclet.
+     *
+     * @apiNote
+     * The environment may be used to access utility classes for
+     * {@link javax.lang.model.util.Elements elements} and
+     * {@link javax.lang.model.util.Types types} if needed.
+     *
+     * @implSpec
+     * This implementation does nothing.
+     *
+     * @param env the environment in which the doclet and taglet are running
+     * @param doclet the doclet that instantiated this taglet
+     */
+    default void init(DocletEnvironment env, Doclet doclet) { }
+
+    /**
      * Returns the string representation of a series of instances of
      * this tag to be included in the generated output.
      * If this taglet is for an {@link #isInlineTag inline} tag} it will
      * be called once per instance of the tag, each time with a singleton list.
      * Otherwise, if this tag is a block tag, it will be called once per
-     * comment, with a list of all the instances of the tag in the comment.
-     * @param tags the list of {@code DocTree} containing one or more
-     *  instances of this tag
+     * comment, with a list of all the instances of the tag in a comment.
+     * @param tags the list of instances of this tag
+     * @param element the element to which the enclosing comment belongs
      * @return the string representation of the tags to be included in
      *  the generated output
      */
-    String toString(List<? extends DocTree> tags);
+    String toString(List<? extends DocTree> tags, Element element);
 
     /**
      * The kind of location in which a tag may be used.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -199,6 +199,7 @@
      */
     protected void addParameters(ExecutableElement member,
             boolean includeAnnotations, Content htmltree, int indentSize) {
+        htmltree.addContent(Contents.ZERO_WIDTH_SPACE);
         htmltree.addContent("(");
         String sep = "";
         List<? extends VariableElement> parameters = member.getParameters();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -240,7 +240,8 @@
      * Constructor. Initializes resource for the
      * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
      */
-    public ConfigurationImpl() {
+    public ConfigurationImpl(Doclet doclet) {
+        super(doclet);
         resources = new Resources(this,
                 Configuration.sharedResourceBundleName,
                 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -69,9 +69,9 @@
     public ConstructorWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
         super(writer, typeElement);
 
-        VisibleMemberMap visibleMemberMap = new VisibleMemberMap(
+        VisibleMemberMap visibleMemberMap = configuration.getVisibleMemberMap(
                 typeElement,
-                VisibleMemberMap.Kind.CONSTRUCTORS, configuration);
+                VisibleMemberMap.Kind.CONSTRUCTORS);
         List<Element> constructors = visibleMemberMap.getMembers(typeElement);
         for (Element constructor : constructors) {
             if (utils.isProtected(constructor) || utils.isPrivate(constructor)) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -48,6 +48,7 @@
  */
 public class Contents {
     public static final Content SPACE = RawHtml.nbsp;
+    public static final Content ZERO_WIDTH_SPACE = RawHtml.zws;
 
     public final Content allClassesLabel;
     public final Content allImplementedInterfacesLabel;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -61,7 +61,7 @@
 public class HtmlDoclet extends AbstractDoclet {
 
     public HtmlDoclet() {
-        configuration = new ConfigurationImpl();
+        configuration = new ConfigurationImpl(this);
     }
 
     @Override // defined by Doclet
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -25,6 +25,7 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -284,12 +285,14 @@
                 additionalModules.remove(m);
         }
         });
+
         // Get all packages for the module and put it in the concealed packages set.
-        (utils.getModulePackageMap().get(mdle)).forEach((pkg) -> {
+        utils.getModulePackageMap().getOrDefault(mdle, Collections.emptySet()).forEach((pkg) -> {
             if (shouldDocument(pkg)) {
                 concealedPackages.add(pkg);
             }
         });
+
         // Get all exported packages for the module using the exports directive for the module.
         (ElementFilter.exportsIn(mdle.getDirectives())).forEach((directive) -> {
             PackageElement p = directive.getPackage();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -47,6 +47,8 @@
 
     public static final Content nbsp = new RawHtml("&nbsp;");
 
+    public static final Content zws = new RawHtml("&#8203;");
+
     /**
      * Constructor to construct a RawHtml object.
      *
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Wed Jul 05 23:09:40 2017 +0200
@@ -229,8 +229,7 @@
                     pkg = (item.m)
                             ? (item.m + "/" + item.l)
                             : item.l;
-                    var s = nestedName(item);
-                    if (exactMatcher.test(s)) {
+                    if (exactMatcher.test(item.l)) {
                         presult.unshift(item);
                         pCount++;
                     } else if (camelCaseMatcher.test(pkg)) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 package jdk.javadoc.internal.doclets.toolkit;
 
 import java.io.*;
+import java.lang.ref.*;
 import java.util.*;
 
 import javax.lang.model.element.Element;
@@ -54,7 +55,9 @@
 import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException;
 import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
 
 import static javax.tools.Diagnostic.Kind.*;
 
@@ -74,6 +77,10 @@
  * @author Jamie Ho
  */
 public abstract class Configuration {
+    /**
+     * The doclet that created this configuration.
+     */
+    public final Doclet doclet;
 
     /**
      * The factory for builders.
@@ -292,6 +299,8 @@
 
     private List<GroupContainer> groups;
 
+    private final Map<TypeElement, EnumMap<Kind, Reference<VisibleMemberMap>>> typeElementMemberCache;
+
     public abstract Messages getMessages();
     public abstract Resources getResources();
 
@@ -342,13 +351,16 @@
             "jdk.javadoc.internal.doclets.toolkit.resources.doclets";
     /**
      * Constructs the configurations needed by the doclet.
+     * @param doclet the doclet that created this configuration
      */
-    public Configuration() {
+    public Configuration(Doclet doclet) {
+        this.doclet = doclet;
         excludedDocFileDirs = new HashSet<>();
         excludedQualifiers = new HashSet<>();
         setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
         metakeywords = new MetaKeywords(this);
         groups = new ArrayList<>(0);
+        typeElementMemberCache = new HashMap<>();
     }
 
     private boolean initialized = false;
@@ -441,6 +453,11 @@
             }
         }
 
+        // add entries for modules which may not have exported packages
+        modules.forEach((ModuleElement mdle) -> {
+            modulePackages.computeIfAbsent(mdle, m -> Collections.emptySet());
+        });
+
         modules.addAll(modulePackages.keySet());
         showModules = !modules.isEmpty();
         for (Set<PackageElement> pkgs : modulePackages.values()) {
@@ -1248,4 +1265,18 @@
     public boolean isAllowScriptInComments() {
         return allowScriptInComments;
     }
+
+    public VisibleMemberMap getVisibleMemberMap(TypeElement te, VisibleMemberMap.Kind kind) {
+        EnumMap<Kind, Reference<VisibleMemberMap>> cacheMap = typeElementMemberCache
+                .computeIfAbsent(te, k -> new EnumMap<>(VisibleMemberMap.Kind.class));
+
+        Reference<VisibleMemberMap> vmapRef = cacheMap.get(kind);
+        // recompute, if referent has been garbage collected
+        VisibleMemberMap vMap = vmapRef == null ? null : vmapRef.get();
+        if (vMap == null) {
+            vMap = new VisibleMemberMap(te, kind, this);
+            cacheMap.put(kind, new SoftReference<>(vMap));
+        }
+        return vMap;
+    }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -90,7 +90,7 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
+        this.visibleMemberMap = configuration.getVisibleMemberMap(typeElement, memberType);
         this.members = this.visibleMemberMap.getMembers(typeElement);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -91,7 +91,7 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
+        this.visibleMemberMap = configuration.getVisibleMemberMap(typeElement, memberType);
         this.members = this.visibleMemberMap.getMembers(typeElement);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -273,8 +273,8 @@
      * @return true if the given package has constant fields to document.
      */
     private boolean hasConstantField (TypeElement typeElement) {
-        VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(typeElement,
-            VisibleMemberMap.Kind.FIELDS, configuration);
+        VisibleMemberMap visibleMemberMapFields = configuration.getVisibleMemberMap(typeElement,
+            VisibleMemberMap.Kind.FIELDS);
         List<Element> fields = visibleMemberMapFields.getLeafMembers();
         for (Element f : fields) {
             VariableElement field = (VariableElement)f;
@@ -329,10 +329,10 @@
          */
         public ConstantFieldBuilder(TypeElement typeElement) {
             this.typeElement = typeElement;
-            visibleMemberMapFields = new VisibleMemberMap(typeElement,
-                VisibleMemberMap.Kind.FIELDS, configuration);
-            visibleMemberMapEnumConst = new VisibleMemberMap(typeElement,
-                VisibleMemberMap.Kind.ENUM_CONSTANTS, configuration);
+            visibleMemberMapFields = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.FIELDS);
+            visibleMemberMapEnumConst = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.ENUM_CONSTANTS);
         }
 
         /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -94,11 +94,8 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        visibleMemberMap =
-                new VisibleMemberMap(
-                typeElement,
-                VisibleMemberMap.Kind.CONSTRUCTORS,
-                configuration);
+        visibleMemberMap = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.CONSTRUCTORS);
         constructors = visibleMemberMap.getMembers(typeElement);
         for (Element ctor : constructors) {
             if (utils.isProtected(ctor) || utils.isPrivate(ctor)) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -89,11 +89,8 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        visibleMemberMap =
-                new VisibleMemberMap(
-                typeElement,
-                VisibleMemberMap.Kind.ENUM_CONSTANTS,
-                configuration);
+        visibleMemberMap = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.ENUM_CONSTANTS);
         enumConstants = visibleMemberMap.getMembers(typeElement);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -90,11 +90,8 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        visibleMemberMap =
-                new VisibleMemberMap(
-                typeElement,
-                VisibleMemberMap.Kind.FIELDS,
-                configuration);
+        visibleMemberMap = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.FIELDS);
         fields = visibleMemberMap.getLeafMembers();
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -32,6 +32,12 @@
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.PrimitiveType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleTypeVisitor9;
 
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.DocTree.Kind;
@@ -64,10 +70,6 @@
     public static final String NAME = "MemberSummary";
 
     /**
-     * The visible members for the given class.
-     */
-    private final EnumMap<VisibleMemberMap.Kind, VisibleMemberMap> visibleMemberMaps;
-    /**
      * The member summary writers for the given class.
      */
     private final EnumMap<VisibleMemberMap.Kind, MemberSummaryWriter> memberSummaryWriters;
@@ -88,14 +90,6 @@
         super(context);
         this.typeElement = typeElement;
         memberSummaryWriters = new EnumMap<>(VisibleMemberMap.Kind.class);
-        visibleMemberMaps = new EnumMap<>(VisibleMemberMap.Kind.class);
-        for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.values()) {
-            visibleMemberMaps.put(kind,
-                    new VisibleMemberMap(
-                    typeElement,
-                    kind,
-                    configuration));
-        }
     }
 
     /**
@@ -111,7 +105,7 @@
                 classWriter.getTypeElement());
         WriterFactory wf = context.configuration.getWriterFactory();
         for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.values()) {
-            MemberSummaryWriter msw = builder.visibleMemberMaps.get(kind).noVisibleMembers()
+            MemberSummaryWriter msw =  builder.getVisibleMemberMap(kind).noVisibleMembers()
                     ? null
                     : wf.getMemberSummaryWriter(classWriter, kind);
             builder.memberSummaryWriters.put(kind, msw);
@@ -132,7 +126,7 @@
                 annotationTypeWriter.getAnnotationTypeElement());
         WriterFactory wf = context.configuration.getWriterFactory();
         for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.values()) {
-            MemberSummaryWriter msw = builder.visibleMemberMaps.get(kind).noVisibleMembers()
+            MemberSummaryWriter msw = builder.getVisibleMemberMap(kind).noVisibleMembers()
                     ? null
                     : wf.getMemberSummaryWriter(annotationTypeWriter, kind);
             builder.memberSummaryWriters.put(kind, msw);
@@ -151,25 +145,25 @@
     /**
      * Return the specified visible member map.
      *
-     * @param type the type of visible member map to return.
+     * @param kind the kind of visible member map to return.
      * @return the specified visible member map.
      * @throws ArrayIndexOutOfBoundsException when the type is invalid.
      * @see VisibleMemberMap
      */
-    public VisibleMemberMap getVisibleMemberMap(VisibleMemberMap.Kind type) {
-        return visibleMemberMaps.get(type);
+    public VisibleMemberMap getVisibleMemberMap(VisibleMemberMap.Kind kind) {
+        return configuration.getVisibleMemberMap(typeElement, kind);
     }
 
     /**.
      * Return the specified member summary writer.
      *
-     * @param type the type of member summary writer to return.
+     * @param kind the kind of member summary writer to return.
      * @return the specified member summary writer.
      * @throws ArrayIndexOutOfBoundsException when the type is invalid.
      * @see VisibleMemberMap
      */
-    public MemberSummaryWriter getMemberSummaryWriter(VisibleMemberMap.Kind type) {
-        return memberSummaryWriters.get(type);
+    public MemberSummaryWriter getMemberSummaryWriter(VisibleMemberMap.Kind kind) {
+        return memberSummaryWriters.get(kind);
     }
 
     /**
@@ -177,13 +171,13 @@
      * This information can be used for doclet specific documentation
      * generation.
      *
-     * @param type the type of members to return.
+     * @param kind the kind of elements to return.
      * @return a list of methods that will be documented.
      * @see VisibleMemberMap
      */
-    public SortedSet<Element> members(VisibleMemberMap.Kind type) {
+    public SortedSet<Element> members(VisibleMemberMap.Kind kind) {
         TreeSet<Element> out = new TreeSet<>(comparator);
-        out.addAll(visibleMemberMaps.get(type).getLeafMembers());
+        out.addAll(getVisibleMemberMap(kind).getLeafMembers());
         return out;
     }
 
@@ -198,7 +192,7 @@
             return !utils.getAnnotationMethods(typeElement).isEmpty();
         }
         for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.values()) {
-            VisibleMemberMap members = visibleMemberMaps.get(kind);
+            VisibleMemberMap members = getVisibleMemberMap(kind);
             if (!members.noVisibleMembers()) {
                 return true;
             }
@@ -216,7 +210,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.ENUM_CONSTANTS);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.ENUM_CONSTANTS);
+                getVisibleMemberMap(VisibleMemberMap.Kind.ENUM_CONSTANTS);
         addSummary(writer, visibleMemberMap, false, memberSummaryTree);
     }
 
@@ -230,7 +224,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS);
+                getVisibleMemberMap(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS);
         addSummary(writer, visibleMemberMap, false, memberSummaryTree);
     }
 
@@ -244,7 +238,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL);
+                getVisibleMemberMap(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL);
         addSummary(writer, visibleMemberMap, false, memberSummaryTree);
     }
 
@@ -258,7 +252,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED);
+                getVisibleMemberMap(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED);
         addSummary(writer, visibleMemberMap, false, memberSummaryTree);
     }
 
@@ -272,7 +266,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.FIELDS);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.FIELDS);
+                getVisibleMemberMap(VisibleMemberMap.Kind.FIELDS);
         addSummary(writer, visibleMemberMap, true, memberSummaryTree);
     }
 
@@ -283,7 +277,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.PROPERTIES);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.PROPERTIES);
+                getVisibleMemberMap(VisibleMemberMap.Kind.PROPERTIES);
         addSummary(writer, visibleMemberMap, true, memberSummaryTree);
     }
 
@@ -297,7 +291,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.INNER_CLASSES);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.INNER_CLASSES);
+                getVisibleMemberMap(VisibleMemberMap.Kind.INNER_CLASSES);
         addSummary(writer, visibleMemberMap, true, memberSummaryTree);
     }
 
@@ -311,7 +305,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.METHODS);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.METHODS);
+               getVisibleMemberMap(VisibleMemberMap.Kind.METHODS);
         addSummary(writer, visibleMemberMap, true, memberSummaryTree);
     }
 
@@ -325,7 +319,7 @@
         MemberSummaryWriter writer =
                 memberSummaryWriters.get(VisibleMemberMap.Kind.CONSTRUCTORS);
         VisibleMemberMap visibleMemberMap =
-                visibleMemberMaps.get(VisibleMemberMap.Kind.CONSTRUCTORS);
+                getVisibleMemberMap(VisibleMemberMap.Kind.CONSTRUCTORS);
         addSummary(writer, visibleMemberMap, false, memberSummaryTree);
     }
 
@@ -440,16 +434,10 @@
 
             if (null != setter) {
                 VariableElement param = setter.getParameters().get(0);
-                String typeName = utils.getTypeName(param.asType(), false);
-                // Removal of type parameters and package information.
-                typeName = typeName.split("<")[0];
-                if (typeName.contains(".")) {
-                    typeName = typeName.substring(typeName.lastIndexOf(".") + 1);
-                }
                 StringBuilder sb = new StringBuilder("#");
                 sb.append(utils.getSimpleName(setter));
                 if (!utils.isTypeVariable(param.asType())) {
-                    sb.append("(").append(typeName).append(")");
+                    sb.append("(").append(utils.getTypeSignature(param.asType(), false, true)).append(")");
                 }
                 blockTags.add(cmtutils.makeSeeTree(sb.toString(), setter));
             }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -94,10 +94,8 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        visibleMemberMap = new VisibleMemberMap(
-                typeElement,
-                VisibleMemberMap.Kind.METHODS,
-                configuration);
+        visibleMemberMap = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.METHODS);
         methods = visibleMemberMap.getLeafMembers();
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -90,11 +90,8 @@
         super(context);
         this.typeElement = typeElement;
         this.writer = writer;
-        visibleMemberMap =
-                new VisibleMemberMap(
-                typeElement,
-                VisibleMemberMap.Kind.PROPERTIES,
-                configuration);
+        visibleMemberMap = configuration.getVisibleMemberMap(typeElement,
+                VisibleMemberMap.Kind.PROPERTIES);
         properties = visibleMemberMap.getMembers(typeElement);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Jul 05 23:09:40 2017 +0200
@@ -787,3 +787,15 @@
     font-style:italic;
     font-size:12px;
 }
+
+.moduleGraph span {
+    display:none;
+    position:absolute;
+}
+.moduleGraph:hover span {
+    display:block;
+    margin: -100px 0 0 100px;
+    z-index: 1;
+}
+
+
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -26,6 +26,7 @@
 package jdk.javadoc.internal.doclets.toolkit.taglets;
 
 import java.io.*;
+import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 
 import javax.lang.model.element.Element;
@@ -39,6 +40,8 @@
 import javax.tools.StandardJavaFileManager;
 
 import com.sun.source.doctree.DocTree;
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.Resources;
@@ -125,6 +128,9 @@
      */
     private List<Taglet> serializedFormTags;
 
+    private final DocletEnvironment docEnv;
+    private final Doclet doclet;
+
     private final Messages messages;
     private final Resources resources;
 
@@ -184,7 +190,7 @@
      * @param showversion true if we want to use @version tags.
      * @param showauthor true if we want to use @author tags.
      * @param javafx indicates whether javafx is active.
-     * @param message the message retriever to print warnings.
+     * @param configuration the configuration for this taglet manager
      */
     public TagletManager(boolean nosince, boolean showversion,
                          boolean showauthor, boolean javafx,
@@ -199,6 +205,8 @@
         this.showversion = showversion;
         this.showauthor = showauthor;
         this.javafx = javafx;
+        this.docEnv = configuration.docEnv;
+        this.doclet = configuration.doclet;
         this.messages = configuration.getMessages();
         this.resources = configuration.getResources();
         initStandardTaglets();
@@ -236,7 +244,7 @@
      */
     public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
         try {
-            ClassLoader tagClassLoader = null;
+            ClassLoader tagClassLoader;
             if (!fileManager.hasLocation(TAGLET_PATH)) {
                 List<File> paths = new ArrayList<>();
                 if (tagletPath != null) {
@@ -249,9 +257,11 @@
                 }
             }
             tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
-            Class<?> customTagClass = tagClassLoader.loadClass(classname);
-            Object instance = customTagClass.getConstructor().newInstance();
-            Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.Taglet)instance);
+            Class<? extends jdk.javadoc.doclet.Taglet> customTagClass =
+                    tagClassLoader.loadClass(classname).asSubclass(jdk.javadoc.doclet.Taglet.class);
+            jdk.javadoc.doclet.Taglet instance = customTagClass.getConstructor().newInstance();
+            instance.init(docEnv, doclet);
+            Taglet newLegacy = new UserTaglet(instance);
             String tname = newLegacy.getName();
             Taglet t = customTags.get(tname);
             if (t != null) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -132,7 +132,7 @@
      */
     public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer){
         Content output = writer.getOutputInstance();
-        output.addContent(new RawHtml(userTaglet.toString(Collections.singletonList(tag))));
+        output.addContent(new RawHtml(userTaglet.toString(Collections.singletonList(tag), element)));
         return output;
     }
 
@@ -144,7 +144,7 @@
         Utils utils = writer.configuration().utils;
         List<? extends DocTree> tags = utils.getBlockTags(holder, getName());
         if (!tags.isEmpty()) {
-            String tagString = userTaglet.toString(tags);
+            String tagString = userTaglet.toString(tags, holder);
             if (tagString != null) {
                 output.addContent(new RawHtml(tagString));
             }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Jul 05 23:09:40 2017 +0200
@@ -725,7 +725,7 @@
         return result.toString();
     }
 
-    private String getTypeSignature(TypeMirror t, boolean qualifiedName, boolean noTypeParameters) {
+    public String getTypeSignature(TypeMirror t, boolean qualifiedName, boolean noTypeParameters) {
         return new SimpleTypeVisitor9<StringBuilder, Void>() {
             final StringBuilder sb = new StringBuilder();
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
 import java.util.Collections;
 import java.util.EnumMap;
 import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -53,6 +54,7 @@
 import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.code.Kinds.Kind;
+import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
@@ -60,8 +62,11 @@
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
+import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Name;
@@ -70,7 +75,10 @@
 import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
 
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+
+import static javax.lang.model.util.Elements.Origin.*;
 import static javax.tools.JavaFileObject.Kind.*;
+
 import static jdk.javadoc.internal.tool.Main.Result.*;
 import static jdk.javadoc.internal.tool.JavadocTool.isValidClassName;
 
@@ -153,10 +161,11 @@
     private final Symtab syms;
     private final Names names;
     private final JavaFileManager fm;
-    private final Location location;
+    private final List<Location> locations;
     private final Modules modules;
     private final Map<ToolOption, Object> opts;
     private final Messager messager;
+    private final JavaCompiler compiler;
 
     private final Map<String, Entry> entries = new LinkedHashMap<>();
 
@@ -201,12 +210,22 @@
         this.modules = Modules.instance(context);
         this.opts = opts;
         this.messager = Messager.instance0(context);
+        this.compiler = JavaCompiler.instance(context);
+        Source source = Source.instance(context);
 
-        this.location = modules.multiModuleMode
-                ? StandardLocation.MODULE_SOURCE_PATH
-                : toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
-                    ? StandardLocation.SOURCE_PATH
-                    : StandardLocation.CLASS_PATH;
+        List<Location> locs = new ArrayList<>();
+        if (modules.multiModuleMode) {
+            locs.add(StandardLocation.MODULE_SOURCE_PATH);
+        } else {
+            if (toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH))
+                locs.add(StandardLocation.SOURCE_PATH);
+            else
+                locs.add(StandardLocation.CLASS_PATH);
+        }
+        if (source.allowModules() && toolEnv.fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH))
+            locs.add(StandardLocation.PATCH_MODULE_PATH);
+        this.locations = Collections.unmodifiableList(locs);
+
         getEntry("").excluded = false;
 
         accessFilter = new ModifierFilter(opts);
@@ -341,6 +360,52 @@
         return this;
     }
 
+    /*
+     * This method sanity checks the following cases:
+     * a. a source-path containing a single module and many modules specified with --module
+     * b. no modules on source-path
+     * c. mismatched source-path and many modules specified with --module
+     */
+    void sanityCheckSourcePathModules(List<String> moduleNames) throws ToolException {
+        if (!haveSourceLocationWithModule)
+            return;
+
+        if (moduleNames.size() > 1) {
+            String text = messager.getText("main.cannot_use_sourcepath_for_modules",
+                    String.join(", ", moduleNames));
+            throw new ToolException(CMDERR, text);
+        }
+
+        String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
+        if (foundModule == null) {
+            String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
+            throw new ToolException(CMDERR, text);
+        }
+
+        if (!moduleNames.get(0).equals(foundModule)) {
+            String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
+            throw new ToolException(CMDERR, text);
+        }
+    }
+
+    private String getModuleName(Location location) throws ToolException {
+        try {
+            JavaFileObject jfo = fm.getJavaFileForInput(location,
+                    "module-info", JavaFileObject.Kind.SOURCE);
+            if (jfo != null) {
+                JCCompilationUnit jcu = compiler.parse(jfo);
+                JCModuleDecl module = TreeInfo.getModule(jcu);
+                if (module != null) {
+                    return module.getName().toString();
+                }
+            }
+        } catch (IOException ioe) {
+            String text = messager.getText("main.file.manager.list", location);
+            throw new ToolException(SYSERR, text, ioe);
+        }
+        return null;
+    }
+
     @SuppressWarnings("unchecked")
     ElementsTable scanSpecifiedItems() throws ToolException {
 
@@ -349,15 +414,17 @@
                 s -> Collections.EMPTY_LIST);
         List<String> mlist = new ArrayList<>();
         for (String m : moduleNames) {
-            Location moduleLoc = getModuleLocation(location, m);
-            if (moduleLoc == null) {
+            List<Location> moduleLocations = getModuleLocation(locations, m);
+            if (moduleLocations.isEmpty()) {
                 String text = messager.getText("main.module_not_found", m);
                 throw new ToolException(CMDERR, text);
-            } else {
-                mlist.add(m);
-                ModuleSymbol msym = syms.enterModule(names.fromString(m));
-                specifiedModuleElements.add((ModuleElement) msym);
+            }
+            if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) {
+                sanityCheckSourcePathModules(moduleNames);
             }
+            mlist.add(m);
+            ModuleSymbol msym = syms.enterModule(names.fromString(m));
+            specifiedModuleElements.add((ModuleElement) msym);
         }
 
         // scan for modules with qualified packages
@@ -448,35 +515,47 @@
         });
 
         for (ModulePackage modpkg : subPackages) {
-            Location packageLocn = getLocation(modpkg);
-            Iterable<JavaFileObject> list = null;
-            try {
-                list = fm.list(packageLocn, modpkg.packageName, sourceKinds, true);
-            } catch (IOException ioe) {
-                String text = messager.getText("main.file.manager.list", modpkg.packageName);
-                throw new ToolException(SYSERR, text, ioe);
+            List<Location> locs = getLocation(modpkg);
+            for (Location loc : locs) {
+                addPackagesFromLocations(loc, modpkg);
             }
-            for (JavaFileObject fo : list) {
-                String binaryName = fm.inferBinaryName(packageLocn, fo);
-                String pn = getPackageName(binaryName);
-                String simpleName = getSimpleName(binaryName);
-                Entry e = getEntry(pn);
-                if (!e.isExcluded() && isValidClassName(simpleName)) {
-                    ModuleSymbol msym = (modpkg.hasModule())
-                            ? syms.getModule(names.fromString(modpkg.moduleName))
-                            : findModuleOfPackageName(modpkg.packageName);
+        }
+    }
+
+    /* Call fm.list and wrap any IOException that occurs in a ToolException */
+    private Iterable<JavaFileObject> fmList(Location location,
+                                            String packagename,
+                                            Set<JavaFileObject.Kind> kinds,
+                                            boolean recurse) throws ToolException {
+        try {
+            return fm.list(location, packagename, kinds, recurse);
+        } catch (IOException ioe) {
+            String text = messager.getText("main.file.manager.list", packagename);
+            throw new ToolException(SYSERR, text, ioe);
+        }
+    }
 
-                    if (msym != null && !msym.isUnnamed()) {
-                        syms.enterPackage(msym, names.fromString(pn));
-                        ModulePackage npkg = new ModulePackage(msym.toString(), pn);
-                        cmdLinePackages.add(npkg);
-                    } else {
-                        cmdLinePackages.add(e.modpkg);
-                    }
-                    e.files = (e.files == null
-                            ? com.sun.tools.javac.util.List.of(fo)
-                            : e.files.prepend(fo));
+    private void addPackagesFromLocations(Location packageLocn, ModulePackage modpkg) throws ToolException {
+        for (JavaFileObject fo : fmList(packageLocn, modpkg.packageName, sourceKinds, true)) {
+            String binaryName = fm.inferBinaryName(packageLocn, fo);
+            String pn = getPackageName(binaryName);
+            String simpleName = getSimpleName(binaryName);
+            Entry e = getEntry(pn);
+            if (!e.isExcluded() && isValidClassName(simpleName)) {
+                ModuleSymbol msym = (modpkg.hasModule())
+                        ? syms.getModule(names.fromString(modpkg.moduleName))
+                        : findModuleOfPackageName(modpkg.packageName);
+
+                if (msym != null && !msym.isUnnamed()) {
+                    syms.enterPackage(msym, names.fromString(pn));
+                    ModulePackage npkg = new ModulePackage(msym.toString(), pn);
+                    cmdLinePackages.add(npkg);
+                } else {
+                    cmdLinePackages.add(e.modpkg);
                 }
+                e.files = (e.files == null
+                        ? com.sun.tools.javac.util.List.of(fo)
+                        : e.files.prepend(fo));
             }
         }
     }
@@ -484,25 +563,51 @@
     /**
      * Returns the "requires" modules for the target module.
      * @param mdle the target module element
-     * @param isPublic true gets all the public requires, otherwise
-     *                 gets all the non-public requires
+     * @param onlyTransitive true gets all the requires transitive, otherwise
+     *                 gets all the non-transitive requires
      *
      * @return a set of modules
      */
-    private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean isPublic) {
+    private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean onlyTransitive) throws ToolException {
         Set<ModuleElement> result = new HashSet<>();
         for (RequiresDirective rd : ElementFilter.requiresIn(mdle.getDirectives())) {
-            if (isPublic && rd.isTransitive()) {
-                result.add(rd.getDependency());
-            }
-            if (!isPublic && !rd.isTransitive()) {
-                result.add(rd.getDependency());
+            ModuleElement dep = rd.getDependency();
+            if (result.contains(dep))
+                continue;
+            if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
+                if (!haveModuleSources(dep)) {
+                    messager.printWarning(dep, "main.module_not_found", dep.getSimpleName());
+                }
+                result.add(dep);
+            } else if (isMandated(mdle, rd) && haveModuleSources(dep)) {
+                result.add(dep);
             }
         }
         return result;
     }
 
-    private void computeSpecifiedModules() {
+    private boolean isMandated(ModuleElement mdle, RequiresDirective rd) {
+        return toolEnv.elements.getOrigin(mdle, rd) == MANDATED;
+    }
+
+    Map<ModuleSymbol, Boolean> haveModuleSourcesCache = new HashMap<>();
+    private boolean haveModuleSources(ModuleElement mdle) throws ToolException {
+        ModuleSymbol msym =  (ModuleSymbol)mdle;
+        if (msym.sourceLocation != null) {
+            return true;
+        }
+        if (msym.patchLocation != null) {
+            Boolean value = haveModuleSourcesCache.get(msym);
+            if (value == null) {
+                value = fmList(msym.patchLocation, "", sourceKinds, true).iterator().hasNext();
+                haveModuleSourcesCache.put(msym, value);
+            }
+            return value;
+        }
+        return false;
+    }
+
+    private void computeSpecifiedModules() throws ToolException {
         if (expandRequires == null) { // no expansion requested
             specifiedModuleElements = Collections.unmodifiableSet(specifiedModuleElements);
             return;
@@ -544,20 +649,17 @@
     private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws ToolException {
         Set<PackageElement> result = new HashSet<>();
         ModuleSymbol msym = (ModuleSymbol) mdle;
-        Location msymloc = getModuleLocation(location, msym.name.toString());
-        try {
-            for (JavaFileObject fo : fm.list(msymloc, "", sourceKinds, true)) {
-                if (fo.getName().endsWith("module-info.java"))
+        List<Location> msymlocs = getModuleLocation(locations, msym.name.toString());
+        for (Location msymloc : msymlocs) {
+            for (JavaFileObject fo : fmList(msymloc, "", sourceKinds, true)) {
+                if (fo.getName().endsWith("module-info.java")) {
                     continue;
+                }
                 String binaryName = fm.inferBinaryName(msymloc, fo);
                 String pn = getPackageName(binaryName);
                 PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn));
                 result.add((PackageElement) psym);
             }
-
-        } catch (IOException ioe) {
-            String text = messager.getText("main.file.manager.list", msymloc.getName());
-            throw new ToolException(SYSERR, text, ioe);
         }
         return result;
     }
@@ -653,10 +755,9 @@
 
         Set<PackageElement> packlist = new LinkedHashSet<>();
         cmdLinePackages.forEach((modpkg) -> {
-            ModuleElement mdle = null;
             PackageElement pkg;
             if (modpkg.hasModule()) {
-                mdle = toolEnv.elements.getModuleElement(modpkg.moduleName);
+                ModuleElement mdle = toolEnv.elements.getModuleElement(modpkg.moduleName);
                 pkg = toolEnv.elements.getPackageElement(mdle, modpkg.packageName);
             } else {
                 pkg = toolEnv.elements.getPackageElement(modpkg.toString());
@@ -741,25 +842,20 @@
         }
 
         ListBuffer<JavaFileObject> lb = new ListBuffer<>();
-        Location packageLocn = getLocation(modpkg);
-        if (packageLocn == null) {
+        List<Location> locs = getLocation(modpkg);
+        if (locs.isEmpty()) {
             return Collections.emptyList();
         }
         String pname = modpkg.packageName;
-
-        try {
-            for (JavaFileObject fo : fm.list(packageLocn, pname, sourceKinds, recurse)) {
+        for (Location packageLocn : locs) {
+            for (JavaFileObject fo : fmList(packageLocn, pname, sourceKinds, recurse)) {
                 String binaryName = fm.inferBinaryName(packageLocn, fo);
                 String simpleName = getSimpleName(binaryName);
                 if (isValidClassName(simpleName)) {
                     lb.append(fo);
                 }
             }
-        } catch (IOException ioe) {
-            String text = messager.getText("main.file.manager.list", pname);
-            throw new ToolException(SYSERR, text, ioe);
         }
-
         return lb.toList();
     }
 
@@ -774,24 +870,49 @@
             return null;
     }
 
-    private Location getLocation(ModulePackage modpkg) throws ToolException {
-        if (location != StandardLocation.MODULE_SOURCE_PATH) {
-            return location;
+    private List<Location> getLocation(ModulePackage modpkg) throws ToolException {
+        if (locations.size() == 1 && !locations.contains(StandardLocation.MODULE_SOURCE_PATH)) {
+            return Collections.singletonList(locations.get(0));
         }
 
         if (modpkg.hasModule()) {
-            return getModuleLocation(location, modpkg.moduleName);
+            return getModuleLocation(locations, modpkg.moduleName);
         }
         // TODO: handle invalid results better.
         ModuleSymbol msym = findModuleOfPackageName(modpkg.packageName);
         if (msym == null) {
-            return null;
+            return Collections.emptyList();
         }
-        return getModuleLocation(location, msym.name.toString());
+        return getModuleLocation(locations, msym.name.toString());
     }
 
-    private Location getModuleLocation(Location location, String msymName)
-            throws ToolException {
+    boolean haveSourceLocationWithModule = false;
+
+    private List<Location> getModuleLocation(List<Location> locations, String msymName) throws ToolException {
+        List<Location> out = new ArrayList<>();
+        // search in the patch module first, this overrides others
+        if (locations.contains(StandardLocation.PATCH_MODULE_PATH)) {
+            Location loc = getModuleLocation(StandardLocation.PATCH_MODULE_PATH, msymName);
+            if (loc != null)
+                out.add(loc);
+        }
+        for (Location location : locations) {
+            // skip patch module, already done
+            if (location == StandardLocation.PATCH_MODULE_PATH) {
+                continue;
+            } else if (location == StandardLocation.MODULE_SOURCE_PATH) {
+                Location loc = getModuleLocation(location, msymName);
+                if (loc != null)
+                    out.add(loc);
+            } else if (location == StandardLocation.SOURCE_PATH) {
+                haveSourceLocationWithModule = true;
+                out.add(StandardLocation.SOURCE_PATH);
+            }
+        }
+        return out;
+    }
+
+    private Location getModuleLocation(Location location, String msymName) throws ToolException {
         try {
             return fm.getLocationForModule(location, msymName);
         } catch (IOException ioe) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -74,12 +74,14 @@
 
     @Override
     public void main(List<JCCompilationUnit> trees) {
-        // count all Enter errors as warnings.
+        // cache the error count if we need to convert Enter errors as warnings.
         int nerrors = messager.nerrors;
         super.main(trees);
         compiler.enterDone();
-        messager.nwarnings += (messager.nerrors - nerrors);
-        messager.nerrors = nerrors;
+        if (toolEnv.ignoreSourceErrors) {
+            messager.nwarnings += (messager.nerrors - nerrors);
+            messager.nerrors = nerrors;
+        }
     }
 
     @Override
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Wed Jul 05 23:09:40 2017 +0200
@@ -160,11 +160,7 @@
             // Parse the files and collect the package names.
             for (String arg: javaNames) {
                 if (fm != null && arg.endsWith(".java") && new File(arg).exists()) {
-                    if (new File(arg).getName().equals("module-info.java")) {
-                        messager.printWarningUsingKey("main.file_ignored", arg);
-                    } else {
-                        parse(fm.getJavaFileObjects(arg), classTrees, true);
-                    }
+                    parse(fm.getJavaFileObjects(arg), classTrees, true);
                 } else if (isValidPackageName(arg)) {
                     packageNames.add(arg);
                 } else if (arg.endsWith(".java")) {
@@ -205,6 +201,11 @@
             // Enter symbols for all files
             toolEnv.notice("main.Building_tree");
             javadocEnter.main(classTrees.toList().appendList(packageTrees));
+
+            if (messager.hasErrors()) {
+                return null;
+            }
+
             etable.setClassDeclList(listClasses(classTrees.toList()));
 
             etable.analyze();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Wed Jul 05 23:09:40 2017 +0200
@@ -88,9 +88,8 @@
  */
 public class Start extends ToolOption.Helper {
 
-    @SuppressWarnings("deprecation")
-    private static final Class<?> OldStdDoclet =
-            com.sun.tools.doclets.standard.Standard.class;
+    private static final String OldStdDocletName =
+        "com.sun.tools.doclets.standard.Standard";
 
     private static final Class<?> StdDoclet =
             jdk.javadoc.doclet.StandardDoclet.class;
@@ -334,7 +333,7 @@
                     messager.getWriter(WriterKind.ERROR),
                     messager.getWriter(WriterKind.WARNING),
                     messager.getWriter(WriterKind.NOTICE),
-                    "com.sun.tools.doclets.standard.Standard",
+                    OldStdDocletName,
                     nargv);
             return (rc == 0) ? OK : ERROR;
         }
@@ -513,12 +512,22 @@
         } catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) {
         }
 
+        Arguments arguments = Arguments.instance(context);
+        arguments.init(ProgramName);
+        arguments.allowEmpty();
+
         doclet.init(locale, messager);
         parseArgs(argList, javaNames);
 
-        Arguments arguments = Arguments.instance(context);
-        arguments.init(ProgramName);
-        arguments.allowEmpty();
+        if (!arguments.handleReleaseOptions(extra -> true)) {
+            // Arguments does not always increase the error count in the
+            // case of errors, so increment the error count only if it has
+            // not been updated previously, preventing complaints by callers
+            if (!messager.hasErrors() && !messager.hasWarnings())
+                messager.nerrors++;
+            return CMDERR;
+        }
+
         if (!arguments.validate()) {
             // Arguments does not always increase the error count in the
             // case of errors, so increment the error count only if it has
@@ -532,49 +541,6 @@
             ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
         }
 
-        String platformString = compOpts.get("--release");
-
-        if (platformString != null) {
-            if (compOpts.isSet("-source")) {
-                String text = messager.getText("main.release.bootclasspath.conflict", "-source");
-                throw new ToolException(CMDERR, text);
-            }
-            if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
-                String text = messager.getText("main.release.bootclasspath.conflict",
-                        BOOT_CLASS_PATH.getPrimaryName());
-                throw new ToolException(CMDERR, text);
-            }
-
-            PlatformDescription platformDescription =
-                    PlatformUtils.lookupPlatformDescription(platformString);
-
-            if (platformDescription == null) {
-                String text = messager.getText("main.unsupported.release.version", platformString);
-                throw new IllegalArgumentException(text);
-            }
-
-            compOpts.put(SOURCE, platformDescription.getSourceVersion());
-
-            context.put(PlatformDescription.class, platformDescription);
-
-            Collection<Path> platformCP = platformDescription.getPlatformPath();
-
-            if (platformCP != null) {
-                if (fileManager instanceof StandardJavaFileManager) {
-                    StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
-                    try {
-                        sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
-                    } catch (IOException ioe) {
-                        throw new ToolException(SYSERR, ioe.getMessage(), ioe);
-                    }
-                } else {
-                    String text = messager.getText("main.release.not.standard.file.manager",
-                                                    platformString);
-                    throw new ToolException(ABNORMAL, text);
-                }
-            }
-        }
-
         compOpts.notifyListeners();
         List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE,
                 s -> Collections.EMPTY_LIST);
@@ -797,27 +763,31 @@
 
         // Step 4: we have a doclet, try loading it
         if (docletName != null) {
-            try {
-                return Class.forName(docletName, true, getClass().getClassLoader());
-            } catch (ClassNotFoundException cnfe) {
-                if (apiMode) {
-                    throw new IllegalArgumentException("Cannot find doclet class " + userDocletName);
-                }
-                String text = messager.getText("main.doclet_class_not_found", userDocletName);
-                throw new ToolException(CMDERR, text, cnfe);
-            }
+            return loadDocletClass(docletName);
         }
 
         // Step 5: we don't have a doclet specified, do we have taglets ?
         if (!userTagletNames.isEmpty() && hasOldTaglet(userTagletNames, userTagletPath)) {
             // found a bogey, return the old doclet
-            return OldStdDoclet;
+            return loadDocletClass(OldStdDocletName);
         }
 
         // finally
         return StdDoclet;
     }
 
+    private Class<?> loadDocletClass(String docletName) throws ToolException {
+        try {
+            return Class.forName(docletName, true, getClass().getClassLoader());
+        } catch (ClassNotFoundException cnfe) {
+            if (apiMode) {
+                throw new IllegalArgumentException("Cannot find doclet class " + docletName);
+            }
+            String text = messager.getText("main.doclet_class_not_found", docletName);
+            throw new ToolException(CMDERR, text, cnfe);
+        }
+    }
+
     /*
      * This method returns true iff it finds a legacy taglet, but for
      * all other conditions including errors it returns false, allowing
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Wed Jul 05 23:09:40 2017 +0200
@@ -103,11 +103,12 @@
 
     final Symbol externalizableSym;
 
-    /**
-     * True if we do not want to print any notifications at all.
-     */
+    /** If true, prevent printing of any notifications. */
     boolean quiet = false;
 
+    /** If true, ignore all errors encountered during Enter. */
+    boolean ignoreSourceErrors = false;
+
     Check chk;
     com.sun.tools.javac.code.Types types;
     JavaFileManager fileManager;
@@ -163,6 +164,7 @@
 
     public void initialize(Map<ToolOption, Object> toolOpts) {
         this.quiet = (boolean)toolOpts.getOrDefault(ToolOption.QUIET, false);
+        this.ignoreSourceErrors = (boolean)toolOpts.getOrDefault(ToolOption.IGNORE_SOURCE_ERRORS, false);
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -329,6 +329,13 @@
         }
     },
 
+    IGNORE_SOURCE_ERRORS("--ignore-source-errors", HIDDEN) {
+        @Override
+        public void process(Helper helper) {
+            helper.jdtoolOpts.put(IGNORE_SOURCE_ERRORS, true);
+        }
+    },
+
     // ----- help options -----
 
     HELP("--help -help", STANDARD) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -85,10 +85,10 @@
 main.opt.expand.requires.desc=\
     Instructs the tool to expand the set of modules to be\n\
     documented. By default, only the modules given explicitly on\n\
-    the command line will be documented. A value of "transitive" will\n\
-    additionally include all "requires transitive" dependencies of\n\
-    those modules. A value of "all" will include all dependencies\n\
-    of those modules.
+    the command line will be documented. A value of "transitive"\n\
+    will additionally include all "requires transitive"\n\
+    dependencies of those modules. A value of "all" will include\n\
+    all dependencies of those modules.
 
 main.opt.help.desc=\
     Display command line options and exit
@@ -258,6 +258,9 @@
 main.invalid_flag=invalid flag: {0}
 main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
 main.module_not_found=module {0} not found.\n
+main.cannot_use_sourcepath_for_modules=cannot use source path for multiple modules {0}
+main.module_not_found_on_sourcepath=module {0} not found on source path
+main.sourcepath_does_not_contain_module=source path does not contain module {0}
 main.cant.read=cannot read {0}
 main.Loading_source_files_for_package=Loading source files for package {0}...
 main.Loading_source_file=Loading source file {0}...
@@ -278,13 +281,9 @@
 main.illegal_locale_name=Locale not available: {0}
 main.malformed_locale_name=Malformed locale name: {0}
 main.file_not_found=File not found: "{0}"
-main.file_ignored=File ignored: "{0}" (not yet supported)
 main.illegal_class_name=Illegal class name: "{0}"
 main.illegal_package_name=Illegal package name: "{0}"
 main.illegal_option_value=Illegal option value: "{0}"
-main.release.bootclasspath.conflict=option {0} cannot be used together with -release
-main.unsupported.release.version=release version {0} not supported
-main.release.not.standard.file.manager=-release option specified, but the provided JavaFileManager is not a StandardJavaFileManager.
 main.file.manager.list=FileManager error listing files: "{0}"
 main.assertion.error=assertion failed: "{0}}"
 main.unknown.error=an unknown error has occurred
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  *  {@link javax.tools.ToolProvider#getSystemDocumentationTool system documentation tool}
  *  and its command line equivalent, <em>javadoc</em>.
  *
+ *  @moduleGraph
  *  @since 9
  */
 module jdk.javadoc {
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -618,7 +618,6 @@
         public Void visitModuleTarget(ModuleTarget_attribute attr, ClassOutputStream out) {
             out.writeShort(attr.os_name_index);
             out.writeShort(attr.os_arch_index);
-            out.writeShort(attr.os_version_index);
             return null;
         }
 
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleTarget_attribute.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleTarget_attribute.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,7 +40,6 @@
         super(name_index, length);
         os_name_index = cr.readUnsignedShort();
         os_arch_index = cr.readUnsignedShort();
-        os_version_index = cr.readUnsignedShort();
     }
 
     @Override
@@ -50,5 +49,4 @@
 
     public final int os_name_index;
     public final int os_arch_index;
-    public final int os_version_index;
 }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -680,12 +680,6 @@
             print("// " + getOSArch(attr));
         }
         println();
-        print("os_version: #" + attr.os_version_index);
-        if (attr.os_version_index != 0) {
-            tab();
-            print("// " + getOSVersion(attr));
-        }
-        println();
         indent(-1);
         return null;
     }
@@ -706,14 +700,6 @@
         }
     }
 
-    private String getOSVersion(ModuleTarget_attribute attr) {
-        try {
-            return constant_pool.getUTF8Value(attr.os_version_index);
-        } catch (ConstantPoolException e) {
-            return report(e);
-        }
-    }
-
     @Override
     public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
         println("RuntimeVisibleAnnotations:");
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -75,24 +75,52 @@
 
 scan.process.class=Processing class {0}...
 
+# The "removal tag": empty for normal deprecations,
+# nonempty for removal deprecations; do not translate.
 scan.dep.normal=
 scan.dep.removal=(forRemoval=true)
 
 scan.err.exception=error: unexpected exception {0}
 scan.err.noclass=error: cannot find class {0}
 scan.err.nofile=error: cannot find file {0}
+
+# 0: class name, 1: method name, 2: parameter and return types
 scan.err.nomethod=error: cannot resolve Methodref {0}.{1}:{2}
 
 scan.head.jar=Jar file {0}:
 scan.head.dir=Directory {0}:
 
+# In all of the messages below, 0 and 1 are as follows:
+#   0: type kind (class, interface, enum, or annotation type)
+#   1: type name
+# The last element is generally a "removal tag"; see above.
+
+# 2: class name, 3: removal tag
 scan.out.extends={0} {1} extends deprecated class {2} {3}
+
+# 2: interface name, 3: removal tag
 scan.out.implements={0} {1} implements deprecated interface {2} {3}
+
+# 2: class name, 3: removal tag
 scan.out.usesclass={0} {1} uses deprecated class {2} {3}
+
+# 2: class name, 3: method name, 4: method parameter and return types, 5: removal tag
 scan.out.usesmethod={0} {1} uses deprecated method {2}::{3}{4} {5}
+
+# 2: class name, 3: method name, 4: method parameter and return types, 5: removal tag
 scan.out.usesintfmethod={0} {1} uses deprecated method {2}::{3}{4} {5}
+
+# 2: class name, 3: field name, 4: removal tag
 scan.out.usesfield={0} {1} uses deprecated field {2}::{3} {4}
+
+# 2: field name, 3: type name, 4: removal tag
 scan.out.hasfield={0} {1} has field named {2} of deprecated type {3} {4}
+
+# 2: method name, 3: parameter type, 4: removal tag
 scan.out.methodparmtype={0} {1} has method named {2} having deprecated parameter type {3} {4}
+
+# 2: method name, 3: return type, 4: removal tag
 scan.out.methodrettype={0} {1} has method named {2} having deprecated return type {3} {4}
+
+# 2: class name, 3: method name, 4: method parameter and return types, 5: removal tag
 scan.out.methodoverride={0} {1} overrides deprecated method {2}::{3}{4} {5}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,6 +32,7 @@
 import java.io.PrintWriter;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.*;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
@@ -39,8 +40,8 @@
 import java.nio.file.Path;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Deque;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -76,10 +77,16 @@
      * @param dir output directory
      */
     public boolean genDotFiles(Path dir) throws IOException {
+        return genDotFiles(dir, DotGraphAttributes.DEFAULT);
+    }
+
+    public boolean genDotFiles(Path dir, Attributes attributes)
+        throws IOException
+    {
         Files.createDirectories(dir);
         for (String mn : configurations.keySet()) {
             Path path = dir.resolve(mn + ".dot");
-            genDotFile(path, mn, configurations.get(mn));
+            genDotFile(path, mn, configurations.get(mn), attributes);
         }
         return true;
     }
@@ -87,7 +94,9 @@
     /**
      * Generate dotfile of the given path
      */
-    public void genDotFile(Path path, String name, Configuration configuration)
+    public void genDotFile(Path path, String name,
+                           Configuration configuration,
+                           Attributes attributes)
         throws IOException
     {
         // transitive reduction
@@ -95,12 +104,12 @@
                 ? requiresTransitiveGraph(configuration, Set.of(name))
                 : gengraph(configuration);
 
-        DotGraphBuilder builder = new DotGraphBuilder(name, graph);
-        builder.subgraph("se", "java", DotGraphBuilder.ORANGE,
+        DotGraphBuilder builder = new DotGraphBuilder(name, graph, attributes);
+        builder.subgraph("se", "java", attributes.javaSubgraphColor(),
                          DotGraphBuilder.JAVA_SE_SUBGRAPH)
-               .subgraph("jdk", "jdk", DotGraphBuilder.BLUE,
+               .subgraph("jdk", "jdk", attributes.jdkSubgraphColor(),
                          DotGraphBuilder.JDK_SUBGRAPH)
-               .descriptors(graph.nodes().stream()
+               .modules(graph.nodes().stream()
                                  .map(mn -> configuration.findModule(mn).get()
                                                 .reference().descriptor()));
         // build dot file
@@ -118,12 +127,12 @@
     private Graph<String> gengraph(Configuration cf) {
         Graph.Builder<String> builder = new Graph.Builder<>();
         cf.modules().stream()
-            .forEach(resolvedModule -> {
-                String mn = resolvedModule.reference().descriptor().name();
+            .forEach(rm -> {
+                String mn = rm.name();
                 builder.addNode(mn);
-                resolvedModule.reads().stream()
-                    .map(ResolvedModule::name)
-                    .forEach(target -> builder.addEdge(mn, target));
+                rm.reads().stream()
+                  .map(ResolvedModule::name)
+                  .forEach(target -> builder.addEdge(mn, target));
             });
 
         Graph<String> rpg = requiresTransitiveGraph(cf, builder.nodes);
@@ -149,22 +158,103 @@
 
             visited.add(mn);
             builder.addNode(mn);
-            ModuleDescriptor descriptor = cf.findModule(mn).get()
-                .reference().descriptor();
-            descriptor.requires().stream()
-                .filter(d -> d.modifiers().contains(TRANSITIVE)
+            cf.findModule(mn).get()
+              .reference().descriptor().requires().stream()
+              .filter(d -> d.modifiers().contains(TRANSITIVE)
                                 || d.name().equals("java.base"))
-                .map(d -> d.name())
-                .forEach(d -> {
-                    deque.add(d);
-                    builder.addEdge(mn, d);
-                });
+              .map(Requires::name)
+              .forEach(d -> {
+                  deque.add(d);
+                  builder.addEdge(mn, d);
+              });
         }
 
         return builder.build().reduce();
     }
 
-    public static class DotGraphBuilder {
+    public interface Attributes {
+        static final String ORANGE = "#e76f00";
+        static final String BLUE = "#437291";
+        static final String BLACK = "#000000";
+        static final String DARK_GRAY = "#999999";
+        static final String LIGHT_GRAY = "#dddddd";
+
+        int fontSize();
+        String fontName();
+        String fontColor();
+
+        int arrowSize();
+        int arrowWidth();
+        String arrowColor();
+
+        default double rankSep() {
+            return 1;
+        }
+
+        default List<Set<String>> ranks() {
+            return Collections.emptyList();
+        }
+
+        default int weightOf(String s, String t) {
+            return 1;
+        }
+
+        default String requiresMandatedColor() {
+            return LIGHT_GRAY;
+        }
+
+        default String javaSubgraphColor() {
+            return ORANGE;
+        }
+
+        default String jdkSubgraphColor() {
+            return BLUE;
+        }
+    }
+
+    static class DotGraphAttributes implements Attributes {
+        static final DotGraphAttributes DEFAULT = new DotGraphAttributes();
+
+        static final String FONT_NAME = "DejaVuSans";
+        static final int FONT_SIZE = 12;
+        static final int ARROW_SIZE = 1;
+        static final int ARROW_WIDTH = 2;
+
+        @Override
+        public int fontSize() {
+            return FONT_SIZE;
+        }
+
+        @Override
+        public String fontName() {
+            return FONT_NAME;
+        }
+
+        @Override
+        public String fontColor() {
+            return BLACK;
+        }
+
+        @Override
+        public int arrowSize() {
+            return ARROW_SIZE;
+        }
+
+        @Override
+        public int arrowWidth() {
+            return ARROW_WIDTH;
+        }
+
+        @Override
+        public String arrowColor() {
+            return DARK_GRAY;
+        }
+    }
+
+    private static class DotGraphBuilder {
+        static final String REEXPORTS = "";
+        static final String REQUIRES = "style=\"dashed\"";
+
         static final Set<String> JAVA_SE_SUBGRAPH = javaSE();
         static final Set<String> JDK_SUBGRAPH = jdk();
 
@@ -215,41 +305,20 @@
             }
         }
 
-        static final String ORANGE = "#e76f00";
-        static final String BLUE = "#437291";
-        static final String GRAY = "#dddddd";
-        static final String BLACK = "#000000";
-
-        static final String FONT_NAME = "DejaVuSans";
-        static final int FONT_SIZE = 12;
-        static final int ARROW_SIZE = 1;
-        static final int ARROW_WIDTH = 2;
-        static final int RANK_SEP = 1;
-
-        static final String REEXPORTS = "";
-        static final String REQUIRES = "style=\"dashed\"";
-        static final String REQUIRES_BASE = "color=\"" + GRAY + "\"";
-
-        // can be configured
-        static double rankSep   = RANK_SEP;
-        static String fontColor = BLACK;
-        static String fontName  = FONT_NAME;
-        static int fontsize     = FONT_SIZE;
-        static int arrowWidth   = ARROW_WIDTH;
-        static int arrowSize    = ARROW_SIZE;
-        static final Map<String, Integer> weights = new HashMap<>();
-        static final List<Set<String>> ranks = new ArrayList<>();
-
         private final String name;
         private final Graph<String> graph;
         private final Set<ModuleDescriptor> descriptors = new TreeSet<>();
         private final List<SubGraph> subgraphs = new ArrayList<>();
-        public DotGraphBuilder(String name, Graph<String> graph) {
+        private final Attributes attributes;
+        public DotGraphBuilder(String name,
+                               Graph<String> graph,
+                               Attributes attributes) {
             this.name = name;
             this.graph = graph;
+            this.attributes = attributes;
         }
 
-        public DotGraphBuilder descriptors(Stream<ModuleDescriptor> descriptors) {
+        public DotGraphBuilder modules(Stream<ModuleDescriptor> descriptors) {
             descriptors.forEach(this.descriptors::add);
             return this;
         }
@@ -260,22 +329,27 @@
 
                 out.format("digraph \"%s\" {%n", name);
                 out.format("  nodesep=.5;%n");
-                out.format("  ranksep=%f;%n", rankSep);
+                out.format("  ranksep=%f;%n", attributes.rankSep());
                 out.format("  pencolor=transparent;%n");
-                out.format("  node [shape=plaintext, fontname=\"%s\", fontsize=%d, margin=\".2,.2\"];%n",
-                           fontName, fontsize);
-                out.format("  edge [penwidth=%d, color=\"#999999\", arrowhead=open, arrowsize=%d];%n",
-                           arrowWidth, arrowSize);
+                out.format("  node [shape=plaintext, fontcolor=\"%s\", fontname=\"%s\","
+                                + " fontsize=%d, margin=\".2,.2\"];%n",
+                           attributes.fontColor(),
+                           attributes.fontName(),
+                           attributes.fontSize());
+                out.format("  edge [penwidth=%d, color=\"%s\", arrowhead=open, arrowsize=%d];%n",
+                           attributes.arrowWidth(),
+                           attributes.arrowColor(),
+                           attributes.arrowSize());
 
                 // same RANKS
-                ranks.stream()
-                     .map(nodes -> descriptors.stream()
+                attributes.ranks().stream()
+                    .map(nodes -> descriptors.stream()
                                         .map(ModuleDescriptor::name)
                                         .filter(nodes::contains)
                                         .map(mn -> "\"" + mn + "\"")
                                         .collect(joining(",")))
-                     .filter(group -> group.length() > 0)
-                     .forEach(group -> out.format("  {rank=same %s}%n", group));
+                    .filter(group -> group.length() > 0)
+                    .forEach(group -> out.format("  {rank=same %s}%n", group));
 
                 subgraphs.forEach(subgraph -> {
                     out.format("  subgraph %s {%n", subgraph.name);
@@ -314,10 +388,14 @@
 
             String mn = md.name();
             edges.stream().forEach(dn -> {
-                String attr = dn.equals("java.base") ? REQUIRES_BASE
-                    : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
+                String attr;
+                if (dn.equals("java.base")) {
+                    attr = "color=\"" + attributes.requiresMandatedColor() + "\"";
+                } else {
+                    attr = (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
+                }
 
-                int w = weightOf(mn, dn);
+                int w = attributes.weightOf(mn, dn);
                 if (w > 1) {
                     if (!attr.isEmpty())
                         attr += ", ";
@@ -328,41 +406,5 @@
             });
         }
 
-        public int weightOf(String s, String t) {
-            int w = weights.getOrDefault(s + ":" + t, 1);
-            if (w != 1)
-                return w;
-            if (s.startsWith("java.") && t.startsWith("java."))
-                return 10;
-            return 1;
-        }
-
-        public static void sameRankNodes(Set<String> nodes) {
-            ranks.add(nodes);
-        }
-
-        public static void weight(String s, String t, int w) {
-            weights.put(s + ":" + t, w);
-        }
-
-        public static void setRankSep(double value) {
-            rankSep = value;
-        }
-
-        public static void setFontSize(int size) {
-            fontsize = size;
-        }
-
-        public static void setFontColor(String color) {
-            fontColor = color;
-        }
-
-        public static void setArrowSize(int size) {
-            arrowSize = size;
-        }
-
-        public static void setArrowWidth(int width) {
-            arrowWidth = width;
-        }
     }
 }
--- a/langtools/src/jdk.jdeps/share/classes/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /** Defines tools for analysing dependencies in Java libraries and programs, including
  *  the <em>jdeps</em> and <em>javap</em> tools.
  *
+ *  @moduleGraph
  *  @since 9
  */
 module jdk.jdeps {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -33,7 +33,6 @@
 import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.io.PrintStream;
-import java.io.UncheckedIOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,7 +43,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Optional;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.BooleanSupplier;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -59,10 +58,10 @@
 import jdk.internal.jline.console.KeyMap;
 import jdk.internal.jline.console.Operation;
 import jdk.internal.jline.console.UserInterruptException;
-import jdk.internal.jline.console.completer.Completer;
 import jdk.internal.jline.console.history.History;
 import jdk.internal.jline.console.history.MemoryHistory;
 import jdk.internal.jline.extra.EditingHistory;
+import jdk.internal.jline.internal.NonBlockingInputStream;
 import jdk.internal.jshell.tool.StopDetectingInputStream.State;
 import jdk.internal.misc.Signal;
 import jdk.internal.misc.Signal.Handler;
@@ -91,10 +90,14 @@
             term = new JShellUnixTerminal(input);
         }
         term.init();
-        AtomicBoolean allowSmart = new AtomicBoolean();
+        List<CompletionTask> completionTODO = new ArrayList<>();
         in = new ConsoleReader(cmdin, cmdout, term) {
             @Override public KeyMap getKeys() {
-                return new CheckCompletionKeyMap(super.getKeys(), allowSmart);
+                return new CheckCompletionKeyMap(super.getKeys(), completionTODO);
+            }
+            @Override
+            protected boolean complete() throws IOException {
+                return ConsoleIOContext.this.complete(completionTODO);
             }
         };
         in.setExpandEvents(false);
@@ -111,67 +114,7 @@
         });
         in.setBellEnabled(true);
         in.setCopyPasteDetection(true);
-        in.addCompleter(new Completer() {
-            @Override public int complete(String test, int cursor, List<CharSequence> result) {
-                int[] anchor = new int[] {-1};
-                List<Suggestion> suggestions;
-                if (prefix.isEmpty() && test.trim().startsWith("/")) {
-                    suggestions = repl.commandCompletionSuggestions(test, cursor, anchor);
-                } else {
-                    int prefixLength = prefix.length();
-                    suggestions = repl.analysis.completionSuggestions(prefix + test, cursor + prefixLength, anchor);
-                    anchor[0] -= prefixLength;
-                }
-                boolean smart = allowSmart.get() &&
-                                suggestions.stream()
-                                           .anyMatch(Suggestion::matchesType);
-
-                allowSmart.set(!allowSmart.get());
-
-                suggestions.stream()
-                           .filter(s -> !smart || s.matchesType())
-                           .map(Suggestion::continuation)
-                           .forEach(result::add);
-
-                boolean onlySmart = suggestions.stream()
-                                               .allMatch(Suggestion::matchesType);
-
-                if (smart && !onlySmart) {
-                    Optional<String> prefix =
-                            suggestions.stream()
-                                       .map(Suggestion::continuation)
-                                       .reduce(ConsoleIOContext::commonPrefix);
-
-                    String prefixStr = prefix.orElse("").substring(cursor - anchor[0]);
-                    try {
-                        in.putString(prefixStr);
-                        cursor += prefixStr.length();
-                    } catch (IOException ex) {
-                        throw new IllegalStateException(ex);
-                    }
-                    result.add(repl.messageFormat("jshell.console.see.more"));
-                    return cursor; //anchor should not be used.
-                }
-
-                if (result.isEmpty()) {
-                    try {
-                        //provide "empty completion" feedback
-                        //XXX: this only works correctly when there is only one Completer:
-                        in.beep();
-                    } catch (IOException ex) {
-                        throw new UncheckedIOException(ex);
-                    }
-                }
-
-                return anchor[0];
-            }
-        });
-        bind(DOCUMENTATION_SHORTCUT, (Runnable) () -> documentation(repl));
-        for (FixComputer computer : FIX_COMPUTERS) {
-            for (String shortcuts : SHORTCUT_FIXES) {
-                bind(shortcuts + computer.shortcut, (Runnable) () -> fixes(computer));
-            }
-        }
+        bind(FIXES_SHORTCUT, (Runnable) () -> fixes());
         try {
             Signal.handle(new Signal("CONT"), new Handler() {
                 @Override public void handle(Signal sig) {
@@ -248,136 +191,184 @@
         }
     }
 
-    private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB
-    private static final String[] SHORTCUT_FIXES = {
-        "\033\015", //Alt-Enter (Linux)
-        "\033\012", //Alt-Enter (Linux)
-        "\033\133\061\067\176", //F6/Alt-F1 (Mac)
-        "\u001BO3P" //Alt-F1 (Linux)
-    };
+    private static final String FIXES_SHORTCUT = "\033\133\132"; //Shift-TAB
 
-    private String lastDocumentationBuffer;
-    private int lastDocumentationCursor = (-1);
+    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+    private static final String LINE_SEPARATORS2 = LINE_SEPARATOR + LINE_SEPARATOR;
 
-    private void documentation(JShellTool repl) {
-        String buffer = in.getCursorBuffer().buffer.toString();
-        int cursor = in.getCursorBuffer().cursor;
-        boolean firstInvocation = !buffer.equals(lastDocumentationBuffer) || cursor != lastDocumentationCursor;
-        lastDocumentationBuffer = buffer;
-        lastDocumentationCursor = cursor;
-        List<String> doc;
-        String seeMore;
-        Terminal term = in.getTerminal();
-        if (prefix.isEmpty() && buffer.trim().startsWith("/")) {
-            doc = Arrays.asList(repl.commandDocumentation(buffer, cursor, firstInvocation));
-            seeMore = "jshell.console.see.help";
-        } else {
-            JavadocFormatter formatter = new JavadocFormatter(term.getWidth(),
-                                                              term.isAnsiSupported());
-            Function<Documentation, String> convertor;
-            if (firstInvocation) {
-                convertor = Documentation::signature;
-            } else {
-                convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) +
-                                 (d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc")
-                                                      : "");
-            }
-            doc = repl.analysis.documentation(prefix + buffer, cursor + prefix.length(), !firstInvocation)
-                               .stream()
-                               .map(convertor)
-                               .collect(Collectors.toList());
-            seeMore = "jshell.console.see.javadoc";
-        }
-
+    @SuppressWarnings("fallthrough")
+    private boolean complete(List<CompletionTask> todo) {
+        //The completion has multiple states (invoked by subsequent presses of <tab>).
+        //On the first invocation in a given sequence, all steps are precomputed
+        //and placed into the todo list. The todo list is then followed on both the first
+        //and subsequent <tab> presses:
         try {
-            if (doc != null && !doc.isEmpty()) {
-                if (firstInvocation) {
-                    in.println();
-                    in.println(doc.stream().collect(Collectors.joining("\n")));
-                    in.println(repl.messageFormat(seeMore));
-                    in.redrawLine();
-                    in.flush();
+            String text = in.getCursorBuffer().toString();
+            int cursor = in.getCursorBuffer().cursor;
+            if (todo.isEmpty()) {
+                int[] anchor = new int[] {-1};
+                List<Suggestion> suggestions;
+                List<String> doc;
+                boolean command = prefix.isEmpty() && text.trim().startsWith("/");
+                if (command) {
+                    suggestions = repl.commandCompletionSuggestions(text, cursor, anchor);
+                    doc = repl.commandDocumentation(text, cursor, true);
                 } else {
-                    in.println();
-
-                    int height = term.getHeight();
-                    String lastNote = "";
+                    int prefixLength = prefix.length();
+                    suggestions = repl.analysis.completionSuggestions(prefix + text, cursor + prefixLength, anchor);
+                    anchor[0] -= prefixLength;
+                    doc = repl.analysis.documentation(prefix + text, cursor + prefix.length(), false)
+                                       .stream()
+                                       .map(Documentation::signature)
+                                       .collect(Collectors.toList());
+                }
+                long smartCount = suggestions.stream().filter(Suggestion::matchesType).count();
+                boolean hasSmart = smartCount > 0 && smartCount <= in.getAutoprintThreshold();
+                boolean hasBoth = hasSmart &&
+                                  suggestions.stream()
+                                             .map(s -> s.matchesType())
+                                             .distinct()
+                                             .count() == 2;
+                boolean tooManyItems = suggestions.size() > in.getAutoprintThreshold();
+                CompletionTask ordinaryCompletion = new OrdinaryCompletionTask(suggestions, anchor[0], !command && !doc.isEmpty(), hasSmart);
+                CompletionTask allCompletion = new AllSuggestionsCompletionTask(suggestions, anchor[0]);
 
-                    PRINT_DOC: for (Iterator<String> docIt = doc.iterator(); docIt.hasNext(); ) {
-                        String currentDoc = docIt.next();
-                        String[] lines = currentDoc.split("\n");
-                        int firstLine = 0;
-
-                        PRINT_PAGE: while (true) {
-                            in.print(lastNote.replaceAll(".", " ") + ConsoleReader.RESET_LINE);
-
-                            int toPrint = height - 1;
-
-                            while (toPrint > 0 && firstLine < lines.length) {
-                                in.println(lines[firstLine++]);
-                                toPrint--;
-                            }
-
-                            if (firstLine >= lines.length) {
-                                break;
-                            }
-
-                            lastNote = repl.getResourceString("jshell.console.see.next.page");
-                            in.print(lastNote + ConsoleReader.RESET_LINE);
-                            in.flush();
-
-                            while (true) {
-                                int r = in.readCharacter();
+                //the main decission tree:
+                if (command) {
+                    CompletionTask shortDocumentation = new CommandSynopsisTask(doc);
+                    CompletionTask fullDocumentation = new CommandFullDocumentationTask(todo);
 
-                                switch (r) {
-                                    case ' ': continue PRINT_PAGE;
-                                    case 'q':
-                                    case 3:
-                                        break PRINT_DOC;
-                                    default:
-                                        in.beep();
-                                        break;
-                                }
-                            }
+                    if (!doc.isEmpty()) {
+                        if (tooManyItems) {
+                            todo.add(new NoopCompletionTask());
+                            todo.add(allCompletion);
+                        } else {
+                            todo.add(ordinaryCompletion);
                         }
+                        todo.add(shortDocumentation);
+                        todo.add(fullDocumentation);
+                    } else {
+                        todo.add(new NoSuchCommandCompletionTask());
+                    }
+                } else {
+                    if (doc.isEmpty()) {
+                        if (hasSmart) {
+                            todo.add(ordinaryCompletion);
+                        } else if (tooManyItems) {
+                            todo.add(new NoopCompletionTask());
+                        }
+                        if (!hasSmart || hasBoth) {
+                            todo.add(allCompletion);
+                        }
+                    } else {
+                        CompletionTask shortDocumentation = new ExpressionSignaturesTask(doc);
+                        CompletionTask fullDocumentation = new ExpressionJavadocTask(todo);
 
-                        if (docIt.hasNext()) {
-                            lastNote = repl.getResourceString("jshell.console.see.next.javadoc");
-                            in.print(lastNote + ConsoleReader.RESET_LINE);
-                            in.flush();
-
-                            while (true) {
-                                int r = in.readCharacter();
-
-                                switch (r) {
-                                    case ' ': continue PRINT_DOC;
-                                    case 'q':
-                                    case 3:
-                                        break PRINT_DOC;
-                                    default:
-                                        in.beep();
-                                        break;
-                                }
-                            }
+                        if (hasSmart) {
+                            todo.add(ordinaryCompletion);
+                        }
+                        todo.add(shortDocumentation);
+                        if (!hasSmart || hasBoth) {
+                            todo.add(allCompletion);
+                        }
+                        if (tooManyItems) {
+                            todo.add(todo.size() - 1, fullDocumentation);
+                        } else {
+                            todo.add(fullDocumentation);
                         }
                     }
-                    //clear the "press space" line:
-                    in.getCursorBuffer().buffer.replace(0, buffer.length(), lastNote);
-                    in.getCursorBuffer().cursor = 0;
-                    in.killLine();
-                    in.getCursorBuffer().buffer.append(buffer);
-                    in.getCursorBuffer().cursor = cursor;
-                    in.redrawLine();
-                    in.flush();
                 }
-            } else {
-                in.beep();
             }
+
+            boolean success = false;
+            boolean repaint = true;
+
+            OUTER: while (!todo.isEmpty()) {
+                CompletionTask.Result result = todo.remove(0).perform(text, cursor);
+
+                switch (result) {
+                    case CONTINUE:
+                        break;
+                    case SKIP_NOREPAINT:
+                        repaint = false;
+                    case SKIP:
+                        todo.clear();
+                        //intentional fall-through
+                    case FINISH:
+                        success = true;
+                        //intentional fall-through
+                    case NO_DATA:
+                        if (!todo.isEmpty()) {
+                            in.println();
+                            in.println(todo.get(0).description());
+                        }
+                        break OUTER;
+                }
+            }
+
+            if (repaint) {
+                in.redrawLine();
+                in.flush();
+            }
+
+            return success;
         } catch (IOException ex) {
             throw new IllegalStateException(ex);
         }
     }
 
+    private CompletionTask.Result doPrintFullDocumentation(List<CompletionTask> todo, List<String> doc, boolean command) {
+        if (doc != null && !doc.isEmpty()) {
+            Terminal term = in.getTerminal();
+            int pageHeight = term.getHeight() - NEEDED_LINES;
+            List<CompletionTask> thisTODO = new ArrayList<>();
+
+            for (Iterator<String> docIt = doc.iterator(); docIt.hasNext(); ) {
+                String currentDoc = docIt.next();
+                String[] lines = currentDoc.split("\n");
+                int firstLine = 0;
+
+                while (firstLine < lines.length) {
+                    boolean first = firstLine == 0;
+                    String[] thisPageLines =
+                            Arrays.copyOfRange(lines,
+                                               firstLine,
+                                               Math.min(firstLine + pageHeight, lines.length));
+
+                    thisTODO.add(new CompletionTask() {
+                        @Override
+                        public String description() {
+                            String key =  !first ? "jshell.console.see.next.page"
+                                                 : command ? "jshell.console.see.next.command.doc"
+                                                           : "jshell.console.see.next.javadoc";
+
+                            return repl.getResourceString(key);
+                        }
+
+                        @Override
+                        public Result perform(String text, int cursor) throws IOException {
+                            in.println();
+                            for (String line : thisPageLines) {
+                                in.println(line);
+                            }
+                            return Result.FINISH;
+                        }
+                    });
+
+                    firstLine += pageHeight;
+                }
+            }
+
+            todo.addAll(0, thisTODO);
+
+            return CompletionTask.Result.CONTINUE;
+        }
+
+        return CompletionTask.Result.FINISH;
+    }
+    //where:
+        private static final int NEEDED_LINES = 4;
+
     private static String commonPrefix(String str1, String str2) {
         for (int i = 0; i < str2.length(); i++) {
             if (!str1.startsWith(str2.substring(0, i + 1))) {
@@ -388,6 +379,262 @@
         return str2;
     }
 
+    private interface CompletionTask {
+        public String description();
+        public Result perform(String text, int cursor) throws IOException;
+
+        enum Result {
+            NO_DATA,
+            CONTINUE,
+            FINISH,
+            SKIP,
+            SKIP_NOREPAINT;
+        }
+    }
+
+    private final class NoopCompletionTask implements CompletionTask {
+
+        @Override
+        public String description() {
+            throw new UnsupportedOperationException("Should not get here.");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            return Result.FINISH;
+        }
+
+    }
+
+    private final class NoSuchCommandCompletionTask implements CompletionTask {
+
+        @Override
+        public String description() {
+            throw new UnsupportedOperationException("Should not get here.");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            in.println();
+            in.println(repl.getResourceString("jshell.console.no.such.command"));
+            in.println();
+            return Result.SKIP;
+        }
+
+    }
+
+    private final class OrdinaryCompletionTask implements CompletionTask {
+        private final List<Suggestion> suggestions;
+        private final int anchor;
+        private final boolean cont;
+        private final boolean smart;
+
+        public OrdinaryCompletionTask(List<Suggestion> suggestions,
+                                      int anchor,
+                                      boolean cont,
+                                      boolean smart) {
+            this.suggestions = suggestions;
+            this.anchor = anchor;
+            this.cont = cont;
+            this.smart = smart;
+        }
+
+        @Override
+        public String description() {
+            throw new UnsupportedOperationException("Should not get here.");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            List<CharSequence> toShow;
+
+            if (smart) {
+                toShow =
+                    suggestions.stream()
+                               .filter(Suggestion::matchesType)
+                               .map(Suggestion::continuation)
+                               .distinct()
+                               .collect(Collectors.toList());
+            } else {
+                toShow =
+                    suggestions.stream()
+                               .map(Suggestion::continuation)
+                               .distinct()
+                               .collect(Collectors.toList());
+            }
+
+            if (toShow.isEmpty()) {
+                return Result.CONTINUE;
+            }
+
+            Optional<String> prefix =
+                    suggestions.stream()
+                               .map(Suggestion::continuation)
+                               .reduce(ConsoleIOContext::commonPrefix);
+
+            String prefixStr = prefix.orElse("").substring(cursor - anchor);
+            in.putString(prefixStr);
+
+            boolean showItems = toShow.size() > 1 || smart;
+
+            if (showItems) {
+                in.println();
+                in.printColumns(toShow);
+            }
+
+            if (!prefixStr.isEmpty())
+                return showItems ? Result.SKIP : Result.SKIP_NOREPAINT;
+
+            return cont ? Result.CONTINUE : Result.FINISH;
+        }
+
+    }
+
+    private final class AllSuggestionsCompletionTask implements CompletionTask {
+        private final List<Suggestion> suggestions;
+        private final int anchor;
+
+        public AllSuggestionsCompletionTask(List<Suggestion> suggestions,
+                                            int anchor) {
+            this.suggestions = suggestions;
+            this.anchor = anchor;
+        }
+
+        @Override
+        public String description() {
+            if (suggestions.size() <= in.getAutoprintThreshold()) {
+                return repl.getResourceString("jshell.console.completion.all.completions");
+            } else {
+                return repl.messageFormat("jshell.console.completion.all.completions.number", suggestions.size());
+            }
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            List<String> candidates =
+                    suggestions.stream()
+                               .map(Suggestion::continuation)
+                               .distinct()
+                               .collect(Collectors.toList());
+
+            Optional<String> prefix =
+                    candidates.stream()
+                              .reduce(ConsoleIOContext::commonPrefix);
+
+            String prefixStr = prefix.map(str -> str.substring(cursor - anchor)).orElse("");
+            in.putString(prefixStr);
+            if (candidates.size() > 1) {
+                in.println();
+                in.printColumns(candidates);
+            }
+            return suggestions.isEmpty() ? Result.NO_DATA : Result.FINISH;
+        }
+
+    }
+
+    private final class CommandSynopsisTask implements CompletionTask {
+
+        private final List<String> synopsis;
+
+        public CommandSynopsisTask(List<String> synposis) {
+            this.synopsis = synposis;
+        }
+
+        @Override
+        public String description() {
+            return repl.getResourceString("jshell.console.see.synopsis");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            try {
+                in.println();
+                in.println(synopsis.stream()
+                                   .map(l -> l.replaceAll("\n", LINE_SEPARATOR))
+                                   .collect(Collectors.joining(LINE_SEPARATORS2)));
+            } catch (IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+            return Result.FINISH;
+        }
+
+    }
+
+    private final class CommandFullDocumentationTask implements CompletionTask {
+
+        private final List<CompletionTask> todo;
+
+        public CommandFullDocumentationTask(List<CompletionTask> todo) {
+            this.todo = todo;
+        }
+
+        @Override
+        public String description() {
+            return repl.getResourceString("jshell.console.see.full.documentation");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            List<String> fullDoc = repl.commandDocumentation(text, cursor, false);
+            return doPrintFullDocumentation(todo, fullDoc, true);
+        }
+
+    }
+
+    private final class ExpressionSignaturesTask implements CompletionTask {
+
+        private final List<String> doc;
+
+        public ExpressionSignaturesTask(List<String> doc) {
+            this.doc = doc;
+        }
+
+        @Override
+        public String description() {
+            throw new UnsupportedOperationException("Should not get here.");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            in.println();
+            in.println(repl.getResourceString("jshell.console.completion.current.signatures"));
+            in.println(doc.stream().collect(Collectors.joining(LINE_SEPARATOR)));
+            return Result.FINISH;
+        }
+
+    }
+
+    private final class ExpressionJavadocTask implements CompletionTask {
+
+        private final List<CompletionTask> todo;
+
+        public ExpressionJavadocTask(List<CompletionTask> todo) {
+            this.todo = todo;
+        }
+
+        @Override
+        public String description() {
+            return repl.getResourceString("jshell.console.see.documentation");
+        }
+
+        @Override
+        public Result perform(String text, int cursor) throws IOException {
+            //schedule showing javadoc:
+            Terminal term = in.getTerminal();
+            JavadocFormatter formatter = new JavadocFormatter(term.getWidth(),
+                                                              term.isAnsiSupported());
+            Function<Documentation, String> convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) +
+                             (d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc")
+                                                  : "");
+            List<String> doc = repl.analysis.documentation(prefix + text, cursor + prefix.length(), true)
+                                            .stream()
+                                            .map(convertor)
+                                            .collect(Collectors.toList());
+            return doPrintFullDocumentation(todo, doc, false);
+        }
+
+    }
+
     @Override
     public boolean terminalEditorRunning() {
         Terminal terminal = in.getTerminal();
@@ -428,6 +675,50 @@
         history.fullHistoryReplace(source);
     }
 
+    private static final long ESCAPE_TIMEOUT = 100;
+
+    private void fixes() {
+        try {
+            int c = in.readCharacter();
+
+            if (c == (-1)) {
+                return ;
+            }
+
+            for (FixComputer computer : FIX_COMPUTERS) {
+                if (computer.shortcut == c) {
+                    fixes(computer);
+                    return ;
+                }
+            }
+
+            readOutRemainingEscape(c);
+
+            in.beep();
+            in.println();
+            in.println(repl.getResourceString("jshell.fix.wrong.shortcut"));
+            in.redrawLine();
+            in.flush();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    private void readOutRemainingEscape(int c) throws IOException {
+        if (c == '\033') {
+            //escape, consume waiting input:
+            InputStream inp = in.getInput();
+
+            if (inp instanceof NonBlockingInputStream) {
+                NonBlockingInputStream nbis = (NonBlockingInputStream) inp;
+
+                while (nbis.isNonBlockingEnabled() && nbis.peek(ESCAPE_TIMEOUT) > 0) {
+                    in.readCharacter();
+                }
+            }
+        }
+    }
+
     //compute possible options/Fixes based on the selected FixComputer, present them to the user,
     //and perform the selected one:
     private void fixes(FixComputer computer) {
@@ -493,7 +784,7 @@
                 in.flush();
             }
         } catch (IOException ex) {
-            ex.printStackTrace();
+            throw new IllegalStateException(ex);
         }
     }
 
@@ -766,7 +1057,7 @@
         public TestTerminal(StopDetectingInputStream input) throws Exception {
             super(true);
             setAnsiSupported(false);
-            setEchoEnabled(true);
+            setEchoEnabled(false);
             this.input = input;
         }
 
@@ -786,12 +1077,12 @@
     private static final class CheckCompletionKeyMap extends KeyMap {
 
         private final KeyMap del;
-        private final AtomicBoolean allowSmart;
+        private final List<CompletionTask> completionTODO;
 
-        public CheckCompletionKeyMap(KeyMap del, AtomicBoolean allowSmart) {
+        public CheckCompletionKeyMap(KeyMap del, List<CompletionTask> completionTODO) {
             super(del.getName(), del.isViKeyMap());
             this.del = del;
-            this.allowSmart = allowSmart;
+            this.completionTODO = completionTODO;
         }
 
         @Override
@@ -819,7 +1110,7 @@
             Object res = del.getBound(keySeq);
 
             if (res != Operation.COMPLETE) {
-                allowSmart.set(true);
+                completionTODO.clear();
             }
 
             return res;
@@ -835,4 +1126,4 @@
             return "check: " + del.toString();
         }
     }
-}
+    }
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1429,9 +1429,15 @@
             List<Suggestion> result;
             int pastSpace = code.indexOf(' ') + 1; // zero if no space
             if (pastSpace == 0) {
+                // initially suggest commands (with slash) and subjects,
+                // however, if their subject starts without slash, include
+                // commands without slash
+                boolean noslash = code.length() > 0 && !code.startsWith("/");
                 result = new FixedCompletionProvider(commands.values().stream()
                         .filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
-                        .map(c -> c.command + " ")
+                        .map(c -> ((noslash && c.command.startsWith("/"))
+                                ? c.command.substring(1)
+                                : c.command) + " ")
                         .toArray(String[]::new))
                         .completionSuggestions(code, cursor, anchor);
             } else if (code.startsWith("/se")) {
@@ -1689,19 +1695,29 @@
         return commandCompletions.completionSuggestions(code, cursor, anchor);
     }
 
-    public String commandDocumentation(String code, int cursor, boolean shortDescription) {
+    public List<String> commandDocumentation(String code, int cursor, boolean shortDescription) {
         code = code.substring(0, cursor);
         int space = code.indexOf(' ');
-
-        if (space != (-1)) {
-            String cmd = code.substring(0, space);
-            Command command = commands.get(cmd);
-            if (command != null) {
-                return getResourceString(command.helpKey + (shortDescription ? ".summary" : ""));
+        String prefix = space != (-1) ? code.substring(0, space) : code;
+        List<String> result = new ArrayList<>();
+
+        List<Entry<String, Command>> toShow =
+                commands.entrySet()
+                        .stream()
+                        .filter(e -> e.getKey().startsWith(prefix))
+                        .filter(e -> e.getValue().kind.showInHelp)
+                        .sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey()))
+                        .collect(Collectors.toList());
+
+        if (toShow.size() == 1) {
+            result.add(getResourceString(toShow.get(0).getValue().helpKey + (shortDescription ? ".summary" : "")));
+        } else {
+            for (Entry<String, Command> e : toShow) {
+                result.add(e.getKey() + "\n" +getResourceString(e.getValue().helpKey + (shortDescription ? ".summary" : "")));
             }
         }
 
-        return null;
+        return result;
     }
 
     // Attempt to stop currently running evaluation
@@ -2087,8 +2103,11 @@
         ArgTokenizer at = new ArgTokenizer("/help", arg);
         String subject = at.next();
         if (subject != null) {
+            // check if the requested subject is a help subject or
+            // a command, with or without slash
             Command[] matches = commands.values().stream()
-                    .filter(c -> c.command.startsWith(subject))
+                    .filter(c -> c.command.startsWith(subject)
+                              || c.command.substring(1).startsWith(subject))
                     .toArray(Command[]::new);
             if (matches.length == 1) {
                 String cmd = matches[0].command;
@@ -2113,6 +2132,18 @@
                 }
                 return true;
             } else {
+                // failing everything else, check if this is the start of
+                // a /set sub-command name
+                String[] subs = Arrays.stream(SET_SUBCOMMANDS)
+                        .filter(s -> s.startsWith(subject))
+                        .toArray(String[]::new);
+                if (subs.length > 0) {
+                    for (String sub : subs) {
+                        hardrb("help.set." + sub);
+                        hard("");
+                    }
+                    return true;
+                }
                 errormsg("jshell.err.help.arg", arg);
             }
         }
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -97,7 +97,10 @@
 jshell.msg.help.subject =\n\
 For more information type ''/help'' followed by the name of a\n\
 command or a subject.\n\
-For example ''/help /list'' or ''/help intro''.  Subjects:\n
+For example ''/help /list'' or ''/help intro''.\n\
+\n\
+Subjects:\n\
+\n
 
 jshell.err.drop.arg =\
 In the /drop argument, please specify an import, variable, method, or class to drop.\n\
@@ -150,12 +153,17 @@
 
 jshell.err.corrupted.stored.startup = Corrupted stored startup, using default -- {0}
 
-jshell.console.see.more = <press tab to see more>
-jshell.console.see.javadoc = <press shift-tab again to see javadoc>
-jshell.console.see.help = <press shift-tab again to see detailed help>
-jshell.console.see.next.page = <press space for next page, Q to quit>
-jshell.console.see.next.javadoc = <press space for next javadoc, Q to quit>
-jshell.console.no.javadoc = <no javadoc found>
+jshell.console.see.synopsis = <press tab again to see synopsis>
+jshell.console.see.full.documentation = <press tab again to see full documentation>
+jshell.console.see.documentation = <press tab again to see documentation>
+jshell.console.see.next.page = <press tab again to see next page>
+jshell.console.see.next.javadoc = <press tab to see next documentation>
+jshell.console.see.next.command.doc = <press tab to see next command>
+jshell.console.no.such.command = No such command
+jshell.console.completion.current.signatures = Signatures:
+jshell.console.completion.all.completions.number = <press tab again to see all possible completions; total possible completions: {0}>
+jshell.console.completion.all.completions = <press tab again to see all possible completions>
+jshell.console.no.javadoc = <no documentation found>
 jshell.console.do.nothing = Do nothing
 jshell.console.choice = Choice: \
 
@@ -403,7 +411,7 @@
 /help\n\t\
      List the jshell commands and help subjects.\n\n\
 /help <command>\n\t\
-     Display information about the specified comand. The slash must be included.\n\t\
+     Display information about the specified command. The slash must be included.\n\t\
      Only the first few letters of the command are needed -- if more than one\n\t\
      each will be displayed.  Example:  /help /li\n\n\
 /help <subject>\n\t\
@@ -444,7 +452,7 @@
 /?\n\t\
      Display list of commands and help subjects.\n\
 /? <command>\n\t\
-     Display information about the specified comand. The slash must be included.\n\t\
+     Display information about the specified command. The slash must be included.\n\t\
      Only the first few letters of the command are needed -- if more than one\n\t\
      match, each will be displayed.  Example:  /? /li\n\
 /? <subject>\n\t\
@@ -478,7 +486,8 @@
 \n\
 For a list of commands: /help
 
-help.shortcuts.summary = a description of shortcuts
+help.shortcuts.summary = a description of keystrokes for snippet and command completion,\n\
+information access, and automatic code generation
 help.shortcuts =\
 Supported shortcuts include:\n\
 \n\
@@ -486,19 +495,16 @@
         After entering the first few letters of a Java identifier,\n\t\t\
         a jshell command, or, in some cases, a jshell command argument,\n\t\t\
         press the <tab> key to complete the input.\n\t\t\
-        If there is more than one completion, show possible completions.\n\n\
-Shift-<tab>\n\t\t\
-        After the name and open parenthesis of a method or constructor invocation,\n\t\t\
-        hold the <shift> key and press the <tab> to see a synopsis of all\n\t\t\
-        matching methods/constructors.\n\n\
-<fix-shortcut> v\n\t\t\
-        After a complete expression, press "<fix-shortcut> v" to introduce a new variable\n\t\t\
-        whose type is based on the type of the expression.\n\t\t\
-        The "<fix-shortcut>" is either Alt-F1 or Alt-Enter, depending on the platform.\n\n\
-<fix-shortcut> i\n\t\t\
-        After an unresolvable identifier, press "<fix-shortcut> i" and jshell will propose\n\t\t\
-        possible fully qualified names based on the content of the specified classpath.\n\t\t\
-        The "<fix-shortcut>" is either Alt-F1 or Alt-Enter, depending on the platform.
+        If there is more than one completion, then possible completions will be shown.\n\t\t\
+        Will show documentation if available and appropriate.\n\n\
+Shift-<tab> v\n\t\t\
+        After a complete expression, hold down <shift> while pressing <tab>,\n\t\t\
+        then release and press "v", the expression will be converted to\n\t\t\
+        a variable declaration whose type is based on the type of the expression.\n\t\t\
+Shift-<tab> i\n\t\t\
+        After an unresolvable identifier, hold down <shift> while pressing <tab>,\n\t\t\
+        then release and press "i", and jshell will propose possible imports\n\t\t\
+        which will resolve the identifier based on the content of the specified classpath.\n\t\t\
 
 help.context.summary = the evaluation context options for /env /reload and /reset
 help.context =\
@@ -791,7 +797,7 @@
 help.set.start =\
 Set the start-up configuration -- a sequence of snippets and commands read at start-up:\n\
 \n\t\
-/set start [-retain] <file>\n\
+/set start [-retain] <file>...\n\
 \n\t\
 /set start [-retain] -default\n\
 \n\t\
@@ -806,9 +812,9 @@
 /set start\n\
 \n\
 The contents of the specified <file> become the start-up snippets and commands used\n\
-when the /reset or /reload commands are used in this session.\n\
-If instead the -default option is specified, the predefined start-up snippets\n\
-will be used.\n\
+when the /reset, /reload, or /env commands are used in this session.\n\
+If instead the -default option is specified, the predefined start-up import\n\
+snippets will be used.\n\
 If the -none option is used, the start-up will be empty -- no start-up snippets\n\
 or commands will be used.\n\
 This command is good for testing the start-up settings.  To retain them for future\n\
@@ -820,7 +826,16 @@
 \n\
 The form without <file> or options shows the start-up setting.\n\
 Note: if the start-up was last set from a file, this is shown with the\n\
-contents of the file followed by a 'set start' command.
+'set start' command followed by the contents of the file.\n\
+\n\
+The <file> may be an operating system file name, or one of the predefined\n\
+startup file names: DEFAULT, PRINTING, or JAVASE.\n\
+These are respectively: the default import snippets (as used by -default),\n\
+definitions of print(), println(), and printf() method snippets, or\n\
+imports of all Java SE packages.\n\
+More than one <file> may be specified, for example:\n\
+\n\t\
+/set start -retain DEFAULT PRINTING
 
 startup.feedback = \
 /set mode verbose -command    \n\
@@ -911,3 +926,7 @@
 /set format silent errorpre '|  '    \n\
 /set format silent errorpost '%n'    \n\
 /set format silent display ''    \n
+
+jshell.fix.wrong.shortcut =\
+Invalid <fix> character.  Use "i" for auto-import or "v" for variable creation.  For more information see:\n\
+   /help shortcuts
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1277,12 +1277,16 @@
                  .allMatch(param -> param.getSimpleName().toString().startsWith("arg"));
     }
 
+    private static List<Path> availableSourcesOverride; //for tests
     private List<Path> availableSources;
 
     private List<Path> findSources() {
         if (availableSources != null) {
             return availableSources;
         }
+        if (availableSourcesOverride != null) {
+            return availableSources = availableSourcesOverride;
+        }
         List<Path> result = new ArrayList<>();
         Path home = Paths.get(System.getProperty("java.home"));
         Path srcZip = home.resolve("lib").resolve("src.zip");
--- a/langtools/src/jdk.jshell/share/classes/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -52,6 +52,7 @@
  *     definitions.
  * </p>
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.jshell {
--- a/langtools/test/ProblemList.txt	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/ProblemList.txt	Wed Jul 05 23:09:40 2017 +0200
@@ -54,6 +54,7 @@
 tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java         8057687    generic-all    emit correct byte code an attributes for type annotations
 tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
 tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java     8160396    generic-all    current version of jtreg needs a new promotion to include lastes version of ASM
+tools/javac/platform/PlatformProviderTest.java                                  8176801    generic-all    fails due to warnings printed to stderr
 
 ###########################################################################
 #
--- a/langtools/test/jdk/javadoc/doclet/testClassLinks/TestClassLinks.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testClassLinks/TestClassLinks.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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,7 +23,7 @@
 
 /*
  * @test
- * @bug 8163800
+ * @bug 8163800 8175200
  * @summary The fix for JDK-8072052 shows up other minor incorrect use of styles
  * @library ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -51,11 +51,11 @@
 
         checkOutput("p/C1.html", true,
                 "<code><a href=\"../p/C2.html\" title=\"class in p\">C2</a></code>",
-                "<code><span class=\"memberNameLink\"><a href=\"../p/C1.html#C1--\">C1</a></span>()</code>");
+                "<code><span class=\"memberNameLink\"><a href=\"../p/C1.html#C1--\">C1</a></span>&#8203;()</code>");
 
         checkOutput("p/C2.html", true,
                 "<code><a href=\"../p/C3.html\" title=\"class in p\">C3</a></code>",
-                "<code><span class=\"memberNameLink\"><a href=\"../p/C2.html#C2--\">C2</a></span>()</code>");
+                "<code><span class=\"memberNameLink\"><a href=\"../p/C2.html#C2--\">C2</a></span>&#8203;()</code>");
 
         checkOutput("p/C3.html", true,
                 "<code><a href=\"../p/I1.html\" title=\"interface in p\">I1</a></code>, "
@@ -63,7 +63,7 @@
                 + "<code><a href=\"../p/I2.html\" title=\"interface in p\">I2</a></code>, "
                 + "<code><a href=\"../p/IT1.html\" title=\"interface in p\">IT1</a>&lt;T&gt;</code>, "
                 + "<code><a href=\"../p/IT2.html\" title=\"interface in p\">IT2</a>&lt;java.lang.String&gt;</code>",
-                "<code><span class=\"memberNameLink\"><a href=\"../p/C3.html#C3--\">C3</a></span>()</code>");
+                "<code><span class=\"memberNameLink\"><a href=\"../p/C3.html#C3--\">C3</a></span>&#8203;()</code>");
 
         checkOutput("p/I1.html", true,
                 "<code><a href=\"../p/C3.html\" title=\"class in p\">C3</a></code>",
--- a/langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -29,9 +29,7 @@
  * @author Jamie Ho
  */
 public enum Coin {
-
-  Penny, Nickel, Dime;
+    Penny, Nickel, Dime;
 
-public Coin(int i) {}
-
+    Coin(int i) {}
 }
--- a/langtools/test/jdk/javadoc/doclet/testConstructors/TestConstructors.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testConstructors/TestConstructors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug 8025524 8031625 8081854
+ * @bug 8025524 8031625 8081854 8175200
  * @summary Test for constructor name which should be a non-qualified name.
  * @author Bhavesh Patel
  * @library ../lib
@@ -58,21 +58,21 @@
                 + "<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>, "
                 + "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>"
                 + "NestedInner(int)</code></a>",
-                "<a href=\"../pkg1/Outer.html#Outer--\">Outer</a></span>()",
+                "<a href=\"../pkg1/Outer.html#Outer--\">Outer</a></span>&#8203;()",
                 "<a name=\"Outer--\">",
-                "<a href=\"../pkg1/Outer.html#Outer-int-\">Outer</a></span>(int&nbsp;i)",
+                "<a href=\"../pkg1/Outer.html#Outer-int-\">Outer</a></span>&#8203;(int&nbsp;i)",
                 "<a name=\"Outer-int-\">");
 
         checkOutput("pkg1/Outer.Inner.html", true,
-                "<a href=\"../pkg1/Outer.Inner.html#Inner--\">Inner</a></span>()",
+                "<a href=\"../pkg1/Outer.Inner.html#Inner--\">Inner</a></span>&#8203;()",
                 "<a name=\"Inner--\">",
-                "<a href=\"../pkg1/Outer.Inner.html#Inner-int-\">Inner</a></span>(int&nbsp;i)",
+                "<a href=\"../pkg1/Outer.Inner.html#Inner-int-\">Inner</a></span>&#8203;(int&nbsp;i)",
                 "<a name=\"Inner-int-\">");
 
         checkOutput("pkg1/Outer.Inner.NestedInner.html", true,
-                "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\">NestedInner</a></span>()",
+                "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\">NestedInner</a></span>&#8203;()",
                 "<a name=\"NestedInner--\">",
-                "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\">NestedInner</a></span>(int&nbsp;i)",
+                "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\">NestedInner</a></span>&#8203;(int&nbsp;i)",
                 "<a name=\"NestedInner-int-\">");
 
         checkOutput("pkg1/Outer.Inner.html", false,
--- a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      4927552 8026567 8071982 8162674
+ * @bug      4927552 8026567 8071982 8162674 8175200
  * @summary  <DESC>
  * @author   jamieh
  * @library  ../lib
@@ -83,10 +83,10 @@
                 + "public&nbsp;int field</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;</div>",
                 "<pre>@Deprecated(forRemoval=true)\n"
-                + "public&nbsp;DeprecatedClassByAnnotation()</pre>\n"
+                + "public&nbsp;DeprecatedClassByAnnotation&#8203;()</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;</div>",
                 "<pre>@Deprecated\n"
-                + "public&nbsp;void&nbsp;method()</pre>\n"
+                + "public&nbsp;void&nbsp;method&#8203;()</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>");
 
         checkOutput("pkg/TestAnnotationType.html", true,
@@ -117,7 +117,7 @@
                 + "public class <span class=\"typeNameLabel\">TestClass</span>\n"
                 + "extends java.lang.Object</pre>",
                 "<pre>@Deprecated(forRemoval=true)\n"
-                + "public&nbsp;TestClass()</pre>\n"
+                + "public&nbsp;TestClass&#8203;()</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;"
                 + "<span class=\"deprecationComment\">class_test3 passes.</span></div>");
 
--- a/langtools/test/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug 6786690 6820360 8025633 8026567
+ * @bug 6786690 6820360 8025633 8026567 8175200
  * @summary This test verifies the nesting of definition list tags.
  * @author Bhavesh Patel
  * @library ../lib
@@ -367,12 +367,12 @@
         // Test with -nocomment and -nodeprecated options. The ClassDocs whould
         // not display definition lists for any member details.
         checkOutput("pkg1/C1.html", expectFound,
-                "<pre>public&nbsp;void&nbsp;readObject()\n" +
+                "<pre>public&nbsp;void&nbsp;readObject&#8203;()\n" +
                 "                throws java.io.IOException</pre>\n" +
                 "</li>");
 
         checkOutput("pkg1/C2.html", expectFound,
-                "<pre>public&nbsp;C2()</pre>\n" +
+                "<pre>public&nbsp;C2&#8203;()</pre>\n" +
                 "</li>");
 
         checkOutput("pkg1/C1.ModalExclusionType.html", expectFound,
--- a/langtools/test/jdk/javadoc/doclet/testIndentation/TestIndentation.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testIndentation/TestIndentation.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      8011288 8062647
+ * @bug      8011288 8062647 8175200
  * @summary  Erratic/inconsistent indentation of signatures
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -46,7 +46,7 @@
         checkExit(Exit.OK);
 
         checkOutput("p/Indent.html", true,
-                "<pre>public&nbsp;&lt;T&gt;&nbsp;void&nbsp;m(T&nbsp;t1,",
+                "<pre>public&nbsp;&lt;T&gt;&nbsp;void&nbsp;m&#8203;(T&nbsp;t1,",
                 "\n"
                 + "                  T&nbsp;t2)",
                 "\n"
--- a/langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      4682448 4947464 5029946 8025633 8026567 8035473 8139101
+ * @bug      4682448 4947464 5029946 8025633 8026567 8035473 8139101 8175200
  * @summary  Verify that the public modifier does not show up in the
  *           documentation for public methods, as recommended by the JLS.
  *           If A implements I and B extends A, B should be in the list of
@@ -64,7 +64,7 @@
         checkExit(Exit.OK);
 
         checkOutput("pkg/Interface.html", true,
-                "<pre>int&nbsp;method()</pre>",
+                "<pre>int&nbsp;method&#8203;()</pre>",
                 "<pre>static final&nbsp;int field</pre>",
                 // Make sure known implementing class list is correct and omits type parameters.
                 "<dl>\n"
@@ -119,7 +119,7 @@
                 + "</dl>");
 
         checkOutput("pkg/Interface.html", false,
-                "public int&nbsp;method()",
+                "public int&nbsp;method&#8203;()",
                 "public static final&nbsp;int field");
 
         checkOutput("pkg/ClassWithStaticMethod.html", false,
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363 8167967 8172528
+ * @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363 8167967 8172528 8175200
  * @summary Test of the JavaFX doclet features.
  * @author jvalenta
  * @library ../lib
@@ -53,11 +53,11 @@
                 + "<dd><a href=\"../pkg1/C.html#getRate--\"><code>getRate()</code></a>, \n"
                 + "<a href=\"../pkg1/C.html#setRate-double-\">"
                 + "<code>setRate(double)</code></a></dd>",
-                "<pre>public final&nbsp;void&nbsp;setRate(double&nbsp;value)</pre>\n"
+                "<pre>public final&nbsp;void&nbsp;setRate&#8203;(double&nbsp;value)</pre>\n"
                 + "<div class=\"block\">Sets the value of the property rate.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
-                "<pre>public final&nbsp;double&nbsp;getRate()</pre>\n"
+                "<pre>public final&nbsp;double&nbsp;getRate&#8203;()</pre>\n"
                 + "<div class=\"block\">Gets the value of the property rate.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
@@ -77,7 +77,7 @@
                 "<span class=\"simpleTagLabel\">Property description:</span>",
                 "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg1/C.html#setTestMethodProperty--\">"
-                + "setTestMethodProperty</a></span>()</code></th>",
+                + "setTestMethodProperty</a></span>&#8203;()</code></th>",
                 "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg1/C.html#pausedProperty\">paused</a></span></code></th>\n"
                 + "<td class=\"colLast\">\n"
@@ -87,10 +87,10 @@
                 + "title=\"class in pkg1\">C.BooleanProperty</a> pausedProperty</pre>\n"
                 + "<div class=\"block\">Defines if paused. The second line.</div>",
                 "<h4>isPaused</h4>\n"
-                + "<pre>public final&nbsp;double&nbsp;isPaused()</pre>\n"
+                + "<pre>public final&nbsp;double&nbsp;isPaused&#8203;()</pre>\n"
                 + "<div class=\"block\">Gets the value of the property paused.</div>",
                 "<h4>setPaused</h4>\n"
-                + "<pre>public final&nbsp;void&nbsp;setPaused(boolean&nbsp;value)</pre>\n"
+                + "<pre>public final&nbsp;void&nbsp;setPaused&#8203;(boolean&nbsp;value)</pre>\n"
                 + "<div class=\"block\">Sets the value of the property paused.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
@@ -98,7 +98,7 @@
                 + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
                 + "<dd>false</dd>",
                 "<h4>isPaused</h4>\n"
-                + "<pre>public final&nbsp;double&nbsp;isPaused()</pre>\n"
+                + "<pre>public final&nbsp;double&nbsp;isPaused&#8203;()</pre>\n"
                 + "<div class=\"block\">Gets the value of the property paused.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
@@ -112,7 +112,7 @@
                 + "<code>Timeline</code> is expected to\n"
                 + " be played. This is the second line.</div>",
                 "<h4>setRate</h4>\n"
-                + "<pre>public final&nbsp;void&nbsp;setRate(double&nbsp;value)</pre>\n"
+                + "<pre>public final&nbsp;void&nbsp;setRate&#8203;(double&nbsp;value)</pre>\n"
                 + "<div class=\"block\">Sets the value of the property rate.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
@@ -123,7 +123,7 @@
                 + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
                 + "<dd>JavaFX 8.0</dd>",
                 "<h4>getRate</h4>\n"
-                + "<pre>public final&nbsp;double&nbsp;getRate()</pre>\n"
+                + "<pre>public final&nbsp;double&nbsp;getRate&#8203;()</pre>\n"
                 + "<div class=\"block\">Gets the value of the property rate.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
@@ -239,26 +239,26 @@
                 + "<td class=\"colFirst\"><code>&lt;T&gt;&nbsp;java.lang.Object</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg2/Test.html#alphaProperty-java.util.List-\">alphaProperty</a>"
-                + "</span>(java.util.List&lt;T&gt;&nbsp;foo)</code></th>\n"
+                + "</span>&#8203;(java.util.List&lt;T&gt;&nbsp;foo)</code></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>\n"
                 + "</tr>\n"
                 + "<tr id=\"i1\" class=\"rowColor\">\n"
                 + "<td class=\"colFirst\"><code>java.lang.Object</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
-                + "<a href=\"../pkg2/Test.html#betaProperty--\">betaProperty</a></span>()</code></th>\n"
+                + "<a href=\"../pkg2/Test.html#betaProperty--\">betaProperty</a></span>&#8203;()</code></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>\n"
                 + "</tr>\n"
                 + "<tr id=\"i2\" class=\"altColor\">\n"
                 + "<td class=\"colFirst\"><code>java.util.List&lt;java.util.Set&lt;? super java.lang.Object&gt;&gt;"
                 + "</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
-                + "<a href=\"../pkg2/Test.html#deltaProperty--\">deltaProperty</a></span>()</code></th>\n"
+                + "<a href=\"../pkg2/Test.html#deltaProperty--\">deltaProperty</a></span>&#8203;()</code></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>\n"
                 + "</tr>\n"
                 + "<tr id=\"i3\" class=\"rowColor\">\n"
                 + "<td class=\"colFirst\"><code>java.util.List&lt;java.lang.String&gt;</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
-                + "<a href=\"../pkg2/Test.html#gammaProperty--\">gammaProperty</a></span>()</code></th>\n"
+                + "<a href=\"../pkg2/Test.html#gammaProperty--\">gammaProperty</a></span>&#8203;()</code></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>"
         );
     }
--- a/langtools/test/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      8004893 8022738 8029143
+ * @bug      8004893 8022738 8029143 8175200
  * @summary  Make sure that the lambda feature changes work fine in
  *           javadoc.
  * @author   bpatel
@@ -55,7 +55,7 @@
 
         checkOutput("pkg/A.html", true,
                 "<td class=\"colFirst\"><code>default void</code></td>",
-                "<pre>default&nbsp;void&nbsp;defaultMethod()</pre>",
+                "<pre>default&nbsp;void&nbsp;defaultMethod&#8203;()</pre>",
                 "<caption><span id=\"t0\" class=\"activeTableTab\"><span>"
                 + "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
                 + "<span id=\"t2\" class=\"tableTab\"><span>"
@@ -83,7 +83,7 @@
 
         checkOutput("pkg/A.html", false,
                 "<td class=\"colFirst\"><code>default default void</code></td>",
-                "<pre>default&nbsp;default&nbsp;void&nbsp;defaultMethod()</pre>");
+                "<pre>default&nbsp;default&nbsp;void&nbsp;defaultMethod&#8203;()</pre>");
 
         checkOutput("pkg/B.html", false,
                 "<td class=\"colFirst\"><code>default void</code></td>",
--- a/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/Check.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/Check.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,6 +24,7 @@
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
+import javax.lang.model.element.Element;
 
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.doclet.Taglet;
@@ -64,10 +65,11 @@
      * representation.
      *
      * @param tags the array of tags representing this custom tag.
+     * @param element the declaration to which the enclosing comment belongs
      * @return null to test if the javadoc throws an exception or not.
      */
     @Override
-    public String toString(List<? extends DocTree> tags) {
+    public String toString(List<? extends DocTree> tags, Element element) {
         return null;
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/ToDoTaglet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/ToDoTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,8 @@
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
-
 import java.util.Set;
+import javax.lang.model.element.Element;
 
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.TextTree;
@@ -87,9 +87,10 @@
      * Given an array of <code>Tag</code>s representing this custom
      * tag, return its string representation.
      * @param tags  the array of <code>DocTree</code>s representing this custom tag.
+     * @param element the declaration to which the enclosing comment belongs
      */
     @Override
-    public String toString(List<? extends DocTree> tags) {
+    public String toString(List<? extends DocTree> tags, Element element) {
         if (tags.isEmpty()) {
             return "";
         }
--- a/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/UnderlineTaglet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testLegacyTaglet/UnderlineTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,6 +24,7 @@
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
+import javax.lang.model.element.Element;
 
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.doclet.Taglet;
@@ -70,9 +71,10 @@
      * Given the <code>DocTree</code> representation of this custom
      * tag, return its string representation.
      * @param tags the <code>DocTree</code> representation of this custom tag.
+     * @param element the declaration to which the enclosing comment belongs
      */
     @Override
-    public String toString(List<? extends DocTree> tags) {
+    public String toString(List<? extends DocTree> tags, Element element) {
         return "<u>" + ToDoTaglet.getText(tags.get(0)) + "</u>";
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      8002387 8014636 8078320
+ * @bug      8002387 8014636 8078320 8175200
  * @summary  Improve rendered HTML formatting for {@code}
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -47,19 +47,19 @@
         checkExit(Exit.OK);
 
         checkOutput("pkg/Test.html", true,
-                "no_pre()</pre>\n"
+                "no_pre&#8203;()</pre>\n"
                 + "<div class=\"block\">abc<code>def</code>ghi</div>",
-                "no_pre_extra_whitespace()</pre>\n"
+                "no_pre_extra_whitespace&#8203;()</pre>\n"
                 + "<div class=\"block\">abc<code> def  </code>ghi</div>",
-                "in_pre()</pre>\n"
+                "in_pre&#8203;()</pre>\n"
                 + "<div class=\"block\"><pre> abc<code> def  </code>ghi</pre></div>",
-                "pre_after_text()</pre>\n"
+                "pre_after_text&#8203;()</pre>\n"
                 + "<div class=\"block\">xyz <pre> abc<code> def  </code>ghi</pre></div>",
-                "after_pre()</pre>\n"
+                "after_pre&#8203;()</pre>\n"
                 + "<div class=\"block\">xyz <pre> pqr </pre> abc<code> def  </code>ghi</div>",
-                "back_in_pre()</pre>\n"
+                "back_in_pre&#8203;()</pre>\n"
                 + "<div class=\"block\">xyz <pre> pqr </pre> mno <pre> abc<code> def  </code>ghi</pre></div>",
-                "typical_usage_code()</pre>\n"
+                "typical_usage_code&#8203;()</pre>\n"
                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
                 + " Example:  <pre><code>\n"
                 + "   line 0 @Override\n"
@@ -68,7 +68,7 @@
                 + "   line 3 }\n"
                 + " </code></pre>\n"
                 + " and so it goes.</div>",
-                "typical_usage_literal()</pre>\n"
+                "typical_usage_literal&#8203;()</pre>\n"
                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
                 + " Example:  <pre>\n"
                 + "   line 0 @Override\n"
@@ -77,7 +77,7 @@
                 + "   line 3 }\n"
                 + " </pre>\n"
                 + " and so it goes.</div>",
-                "recommended_usage_literal()</pre>\n"
+                "recommended_usage_literal&#8203;()</pre>\n"
                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
                 + " Example:  <pre>\n"
                 + "   line 0 @Override\n"
@@ -89,7 +89,7 @@
                 + " <PRE>\n"
                 + " <b>id           </b>\n"
                 + " </PRE></div>",
-                "<pre>public&nbsp;void&nbsp;htmlAttrInPre1()</pre>\n"
+                "<pre>public&nbsp;void&nbsp;htmlAttrInPre1&#8203;()</pre>\n"
                 + "<div class=\"block\">More html tag outliers.\n"
                 + " <pre>\n"
                 + " @Override\n"
--- a/langtools/test/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363
+ * @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200
  * @summary Test to make sure that members are inherited properly in the Javadoc.
  *          Verify that inheritence labels are correct.
  * @author jamieh
@@ -92,7 +92,7 @@
                 "<td class=\"colFirst\"><code>static java.time.Period</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg1/Implementer.html#between-java.time.LocalDate-java.time.LocalDate-\">"
-                + "between</a></span>(java.time.LocalDate&nbsp;startDateInclusive,\n"
+                + "between</a></span>&#8203;(java.time.LocalDate&nbsp;startDateInclusive,\n"
                 + "       java.time.LocalDate&nbsp;endDateExclusive)</code></th>",
                 // check the inherited from interfaces
                 "<h3>Methods inherited from interface&nbsp;pkg1.<a href=\"../pkg1/Interface.html\""
--- a/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      4951228 6290760 8025633 8026567 8081854 8162363
+ * @bug      4951228 6290760 8025633 8026567 8081854 8162363 8175200
  * @summary  Test the case where the overriden method returns a different
  *           type than the method in the child class.  Make sure the
  *           documentation is inherited but the return type isn't.
@@ -52,10 +52,10 @@
                 // Check return type in member summary.
                 "<code><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</a></code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href=\"../pkg/PublicChild.html#returnTypeTest--\">"
-                + "returnTypeTest</a></span>()</code>",
+                + "returnTypeTest</a></span>&#8203;()</code>",
                 // Check return type in member detail.
                 "<pre>public&nbsp;<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">"
-                + "PublicChild</a>&nbsp;returnTypeTest()</pre>");
+                + "PublicChild</a>&nbsp;returnTypeTest&#8203;()</pre>");
 
         // Legacy anchor dimensions (6290760)
         checkOutput("pkg2/A.html", true,
--- a/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java	Wed Jul 05 23:09:40 2017 +0200
@@ -44,7 +44,8 @@
                 "-use",
                 "-sourcepath", testSrc,
                 "p");
-        checkExit(Exit.OK);
-        checkFiles(true, "p/class-use/MissingType.html");
+        checkExit(Exit.ERROR);
+        checkOutput(Output.STDERR, false,
+                "java.lang.UnsupportedOperationException: should not happen");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
- *      8168766 8168688 8162674 8160196 8175799 8174974
+ *      8168766 8168688 8162674 8160196 8175799 8174974 8176778
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -182,6 +182,19 @@
     }
 
     /**
+     * Test generated module summary page of an aggregating module.
+     */
+    @Test
+    void testAggregatorModuleSummary() {
+        javadoc("-d", "out-aggregatorModuleSummary", "-use",
+                "--module-source-path", testSrc,
+                "--expand-requires", "transitive",
+                "--module", "moduleT");
+        checkExit(Exit.OK);
+        checkAggregatorModuleSummary();
+    }
+
+    /**
      * Test generated module pages and pages with link to modules.
      */
     @Test
@@ -599,6 +612,32 @@
                 + "</tr>");
     }
 
+    void checkAggregatorModuleSummary() {
+        checkOutput("moduleT-summary.html", true,
+                "<div class=\"header\">\n"
+                + "<h1 title=\"Module\" class=\"title\">Module&nbsp;moduleT</h1>\n"
+                + "</div>",
+                "<div class=\"block\">This is a test description for the moduleT module. "
+                + "Search phrase <a id=\"searchphrase\">search phrase</a>. "
+                + "Make sure there are no exported packages.</div>",
+                "<tbody>\n"
+                + "<tr class=\"altColor\">\n"
+                + "<td class=\"colFirst\">transitive</td>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
+                + "<td class=\"colLast\">\n"
+                + "<div class=\"block\">This is a test description for the moduleA module.</div>\n"
+                + "</td>\n"
+                + "</tr>\n"
+                + "<tr class=\"rowColor\">\n"
+                + "<td class=\"colFirst\">transitive</td>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
+                + "<td class=\"colLast\">\n"
+                + "<div class=\"block\">This is a test description for the moduleB module.</div>\n"
+                + "</td>\n"
+                + "</tr>\n"
+                + "</tbody>");
+    }
+
     void checkNegatedModuleSummary() {
         checkOutput("moduleA-summary.html", false,
                 "<!-- ============ SERVICES SUMMARY =========== -->\n"
--- a/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -28,7 +28,7 @@
 /**
  * This is a test annotation type.
  */
-@Documented public @interface AnnotationType {
+@Documented @Target(ElementType.MODULE)   public @interface AnnotationType {
 
     /**
      * The copyright holder.
--- a/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -29,7 +29,7 @@
  * This is a test annotation type this is not documented because it
  * is missing the @Documented tag.
  */
-public @interface AnnotationTypeUndocumented {
+@Target(ElementType.MODULE) public @interface AnnotationTypeUndocumented {
 
     /**
      * The copyright holder.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleT/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+  * This is a test description for the moduleT module. Search phrase {@index "search phrase" with description}. Make sure there are no exported packages.
+  *
+  */
+module moduleT {
+    requires transitive moduleA;
+    requires transitive moduleB;
+}
--- a/langtools/test/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug      4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 8162363
+ *           8175200
  * @summary  Run Javadoc on a set of source files that demonstrate new
  *           language features.  Check the output to ensure that the new
  *           language features are properly documented.
@@ -80,7 +81,7 @@
                 "Overloaded valueOf() method has correct documentation.",
                 "Overloaded values method  has correct documentation.",
                 "<pre>public static&nbsp;<a href=\"../pkg/Coin.html\" title=\"enum in pkg\">Coin</a>" +
-                "&nbsp;valueOf(java.lang.String&nbsp;name)</pre>\n" +
+                "&nbsp;valueOf&#8203;(java.lang.String&nbsp;name)</pre>\n" +
                 "<div class=\"block\">Returns the enum constant of this type with the specified name.\n" +
                 "The string must match <i>exactly</i> an identifier used to declare an\n" +
                 "enum constant in this type.  (Extraneous whitespace characters are \n" +
@@ -136,17 +137,17 @@
                 + "title=\"type parameter in TypeParameters\">E</a>[]</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg/TypeParameters.html#methodThatReturnsTypeParameterA-E:A-\">"
-                + "methodThatReturnsTypeParameterA</a></span>(<a href=\"../pkg/TypeParameters.html\" "
+                + "methodThatReturnsTypeParameterA</a></span>&#8203;(<a href=\"../pkg/TypeParameters.html\" "
                 + "title=\"type parameter in TypeParameters\">E</a>[]&nbsp;e)</code>",
                 "<pre>public&nbsp;<a href=\"../pkg/TypeParameters.html\" "
                 + "title=\"type parameter in TypeParameters\">E</a>[]&nbsp;"
-                + "methodThatReturnsTypeParameterA(<a href=\"../pkg/TypeParameters.html\" "
+                + "methodThatReturnsTypeParameterA&#8203;(<a href=\"../pkg/TypeParameters.html\" "
                 + "title=\"type parameter in TypeParameters\">E</a>[]&nbsp;e)</pre>\n",
                 "<td class=\"colFirst\"><code>&lt;T extends java.lang.Object &amp; java.lang.Comparable&lt;? super T&gt;&gt;"
                 + "<br>T</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg/TypeParameters.html#methodtThatReturnsTypeParametersB-java.util.Collection-\">"
-                + "methodtThatReturnsTypeParametersB</a></span>(java.util.Collection&lt;? extends T&gt;&nbsp;coll)</code>",
+                + "methodtThatReturnsTypeParametersB</a></span>&#8203;(java.util.Collection&lt;? extends T&gt;&nbsp;coll)</code>",
                 "<div class=\"block\">Returns TypeParameters</div>\n",
                 // Method takes a TypeVariable
                 "<td class=\"colFirst\"><code>&lt;X extends java.lang.Throwable&gt;<br>"
@@ -154,7 +155,7 @@
                 + "</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../pkg/TypeParameters.html#orElseThrow-java.util.function.Supplier-\">"
-                + "orElseThrow</a></span>(java.util.function.Supplier&lt;? extends X&gt;&nbsp;exceptionSupplier)</code>"
+                + "orElseThrow</a></span>&#8203;(java.util.function.Supplier&lt;? extends X&gt;&nbsp;exceptionSupplier)</code>"
                 );
 
         checkOutput("pkg/Wildcards.html", true,
@@ -208,7 +209,7 @@
         // Handle multiple bounds.
         //==============================================================
         checkOutput("pkg/MultiTypeParameters.html", true,
-                "public&nbsp;&lt;T extends java.lang.Number &amp; java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)");
+                "public&nbsp;&lt;T extends java.lang.Number &amp; java.lang.Runnable&gt;&nbsp;T&nbsp;foo&#8203;(T&nbsp;t)");
 
         //==============================================================
         // Test Class-Use Documentation for Type Parameters.
@@ -231,7 +232,7 @@
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest1."
                 + "</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/"
                 + "ClassUseTest1.html#method-T-\">method</a></span>"
-                + "(T&nbsp;t)</code></th>",
+                + "&#8203;(T&nbsp;t)</code></th>",
                 "<caption><span>Fields in <a href=\"../../pkg2/"
                 + "package-summary.html\">pkg2</a> with type parameters of "
                 + "type <a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">"
@@ -272,7 +273,7 @@
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">"
                 + "ClassUseTest1.</span><code><span class=\"memberNameLink\"><a href=\"../../"
                 + "pkg2/ClassUseTest1.html#method-T-\">method</a></span>"
-                + "(T&nbsp;t)</code></th>"
+                + "&#8203;(T&nbsp;t)</code></th>"
         );
 
         // ClassUseTest2: <T extends ParamTest<Foo3>>
@@ -295,7 +296,7 @@
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest2."
                 + "</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/"
                 + "ClassUseTest2.html#method-T-\">method</a></span>"
-                + "(T&nbsp;t)</code></th>",
+                + "&#8203;(T&nbsp;t)</code></th>",
                 "<caption><span>Fields in <a href=\"../../pkg2/"
                 + "package-summary.html\">pkg2</a> declared as <a href=\"../"
                 + "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest"
@@ -336,7 +337,7 @@
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest2."
                 + "</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/"
                 + "ClassUseTest2.html#method-T-\">method</a></span>"
-                + "(T&nbsp;t)</code></th>",
+                + "&#8203;(T&nbsp;t)</code></th>",
                 "<caption><span>Methods in <a href=\"../../pkg2/"
                 + "package-summary.html\">pkg2</a> that return types with "
                 + "arguments of type <a href=\"../../pkg2/Foo3.html\" title"
@@ -370,7 +371,7 @@
                 + "&nbsp;</span></caption>",
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest3"
                 + ".</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/ClassUseTest3."
-                + "html#method-T-\">method</a></span>(T&nbsp;t)</code></th>",
+                + "html#method-T-\">method</a></span>&#8203;(T&nbsp;t)</code></th>",
                 "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../"
                 + "../pkg2/ParamTest2.html\" title=\"class in pkg2\">"
                 + "ParamTest2</a>&lt;java.util.List&lt;? extends <a href=\".."
@@ -399,7 +400,7 @@
                 + "pkg2\">Foo4</a></span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest3."
                 + "</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/ClassUseTest3."
-                + "html#method-T-\">method</a></span>(T&nbsp;t)</code>"
+                + "html#method-T-\">method</a></span>&#8203;(T&nbsp;t)</code>"
                 + "</th>",
                 "<caption><span>Methods in <a href=\"../../pkg2/"
                 + "package-summary.html\">pkg2</a> that return types with "
@@ -433,7 +434,7 @@
                 + "<td class=\"colFirst\"><code>void</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><span class=\"typeNameLabel\">ClassUseTest3."
                 + "</span><code><span class=\"memberNameLink\"><a href=\"../../pkg2/ClassUseTest3."
-                + "html#method-java.util.Set-\">method</a></span>(java."
+                + "html#method-java.util.Set-\">method</a></span>&#8203;(java."
                 + "util.Set&lt;<a href=\"../../pkg2/Foo4.html\" title=\""
                 + "class in pkg2\">Foo4</a>&gt;&nbsp;p)</code></th>",
                 "<caption><span>Constructor parameters in <a href=\"../../"
@@ -548,7 +549,7 @@
                 + "=\"Constructor Annotation\",\n"
                 + "                <a href=\"../pkg/AnnotationType.html#required--\">"
                 + "required</a>=1994)\n"
-                + "public&nbsp;AnnotationTypeUsage()</pre>",
+                + "public&nbsp;AnnotationTypeUsage&#8203;()</pre>",
                 // METHOD
                 "<pre><a href=\"../pkg/AnnotationType.html\" "
                 + "title=\"annotation in pkg\">@AnnotationType</a>("
@@ -556,9 +557,9 @@
                 + "=\"Method Annotation\",\n"
                 + "                <a href=\"../pkg/AnnotationType.html#required--\">"
                 + "required</a>=1994)\n"
-                + "public&nbsp;void&nbsp;method()</pre>",
+                + "public&nbsp;void&nbsp;method&#8203;()</pre>",
                 // METHOD PARAMS
-                "<pre>public&nbsp;void&nbsp;methodWithParams("
+                "<pre>public&nbsp;void&nbsp;methodWithParams&#8203;("
                 + "<a href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">"
                 + "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional--\">"
                 + "optional</a>=\"Parameter Annotation\",<a "
@@ -566,7 +567,7 @@
                 + "                             int&nbsp;documented,\n"
                 + "                             int&nbsp;undocmented)</pre>",
                 // CONSTRUCTOR PARAMS
-                "<pre>public&nbsp;AnnotationTypeUsage(<a "
+                "<pre>public&nbsp;AnnotationTypeUsage&#8203;(<a "
                 + "href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">"
                 + "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional--\">"
                 + "optional</a>=\"Constructor Param Annotation\",<a "
@@ -629,11 +630,11 @@
                 // CONSTRUCTOR
                 "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Constructor Annotation\",\n"
                 + "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)\n"
-                + "public <span class=\"typeNameLabel\">AnnotationTypeUsage</span>()",
+                + "public <span class=\"typeNameLabel\">AnnotationTypeUsage</span>&#8203;()",
                 // METHOD
                 "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Method Annotation\",\n"
                 + "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)\n"
-                + "public void <span class=\"memberNameLabel\">method</span>()");
+                + "public void <span class=\"memberNameLabel\">method</span>&#8203;()");
 
         //=================================
         // Make sure annotation types do not
--- a/langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      4749567 8071982
+ * @bug      4749567 8071982 8175200
  * @summary  Test the output for -header, -footer, -nooverview, -nodeprecatedlist, -nonavbar, -notree, -stylesheetfile options.
  * @author   Bhavesh Patel
  * @library  ../lib
@@ -148,7 +148,7 @@
                 "<pre>public&nbsp;java.lang.Object <a href="
                 + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a></pre>",
                 "<pre>public&nbsp;java.lang.Object&nbsp;<a href="
-                + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a>()</pre>");
+                + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a>&#8203;()</pre>");
 
         checkOutput("src-html/linksource/Properties.html", true,
                 "<title>Source code</title>",
@@ -161,9 +161,9 @@
                 "<pre>public&nbsp;int <a href=\"../src-html/linksource/SomeClass.html#line.31\">"
                 + "field</a></pre>",
                 "<pre>public&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.33\">"
-                + "SomeClass</a>()</pre>",
+                + "SomeClass</a>&#8203;()</pre>",
                 "<pre>public&nbsp;int&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.36\">"
-                + "method</a>()</pre>");
+                + "method</a>&#8203;()</pre>");
 
         checkOutput("src-html/linksource/SomeClass.html", true,
                 "<title>Source code</title>",
--- a/langtools/test/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      8174839
+ * @bug      8174839 8175200
  * @summary  Bad overriding method should not crash
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -52,7 +52,7 @@
         checkOutput("pkg4/Foo.html", true,
                 "<li class=\"blockList\">\n"
                 + "<h4>toString</h4>\n"
-                + "<pre>public&nbsp;void&nbsp;toString()</pre>\n"
+                + "<pre>public&nbsp;void&nbsp;toString&#8203;()</pre>\n"
                 + "<div class=\"block\">Why can't I do this ?</div>\n"
                 + "</li>");
     }
--- a/langtools/test/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      4780441 4874845 4978816 8014017 8016328 8025633 8026567
+ * @bug      4780441 4874845 4978816 8014017 8016328 8025633 8026567 8175200
  * @summary  Make sure that when the -private flag is not used, members
  *           inherited from package private class are documented in the child.
  *
@@ -74,7 +74,7 @@
                 + "</li>\n"
                 + "</ul>",
                 // Method is documented as though it is declared in the inheriting method.
-                "<pre>public&nbsp;void&nbsp;methodInheritedFromParent(int&nbsp;p1)",
+                "<pre>public&nbsp;void&nbsp;methodInheritedFromParent&#8203;(int&nbsp;p1)",
                 "<dl>\n"
                 + "<dt>All Implemented Interfaces:</dt>\n"
                 + "<dd><code><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">"
@@ -96,12 +96,12 @@
                 // Should not document comments from private inherited interfaces
                 "<td class=\"colLast\"><code><span class=\"memberNameLink\">" +
                 "<a href=\"../pkg/PublicChild.html#methodInterface-int-\">" +
-                "methodInterface</a></span>(int&nbsp;p1)</code>\n" +
+                "methodInterface</a></span>&#8203;(int&nbsp;p1)</code>\n" +
                 "<div class=\"block\">Comment from interface.</div>\n</td>",
                 // and similarly one more
                 "<td class=\"colLast\"><code><span class=\"memberNameLink\">" +
                 "<a href=\"../pkg/PublicChild.html#methodInterface2-int-\">" +
-                "methodInterface2</a></span>(int&nbsp;p1)</code>\n" +
+                "methodInterface2</a></span>&#8203;(int&nbsp;p1)</code>\n" +
                 "<div class=\"block\">Comment from interface.</div>\n</td>"
         );
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/TestProperty.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 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      8176231
+ * @summary  Test JavaFX property.
+ * @library  ../lib/
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build    JavadocTester TestProperty
+ * @run main TestProperty
+ */
+
+public class TestProperty extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestProperty tester = new TestProperty();
+        tester.runTests();
+    }
+
+    @Test
+    void testArrays() {
+        javadoc("-d", "out",
+                "-javafx",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkOutput("pkg/MyClass.html", true,
+                "<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+                + "title=\"class in pkg\">ObjectProperty</a>"
+                + "&lt;<a href=\"../pkg/MyObj.html\" "
+                + "title=\"class in pkg\">MyObj</a>&gt; goodProperty</pre>\n"
+                + "<div class=\"block\">This is an Object property where the "
+                + "Object is a single Object.</div>\n"
+                + "<dl>\n"
+                + "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+                + "<dd><a href=\"../pkg/MyClass.html#getGood--\"><code>getGood()</code></a>, \n"
+                + "<a href=\"../pkg/MyClass.html#setGood-pkg.MyObj-\">"
+                + "<code>setGood(MyObj)</code></a></dd>\n"
+                + "</dl>",
+
+                "<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+                + "title=\"class in pkg\">ObjectProperty</a>"
+                + "&lt;<a href=\"../pkg/MyObj.html\" "
+                + "title=\"class in pkg\">MyObj</a>[]&gt; badProperty</pre>\n"
+                + "<div class=\"block\">This is an Object property where the "
+                + "Object is an array.</div>\n"
+                + "<dl>\n"
+                + "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+                + "<dd><a href=\"../pkg/MyClass.html#getBad--\"><code>getBad()</code></a>, \n"
+                + "<a href=\"../pkg/MyClass.html#setBad-pkg.MyObj:A-\">"
+                + "<code>setBad(MyObj[])</code></a></dd>\n"
+                + "</dl>"
+        );
+
+        checkOutput("pkg/MyClassT.html", true,
+                "<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+                + "title=\"class in pkg\">ObjectProperty</a>"
+                + "&lt;java.util.List&lt;<a href=\"../pkg/MyClassT.html\" "
+                + "title=\"type parameter in MyClassT\">T</a>&gt;&gt; "
+                + "listProperty</pre>\n"
+                + "<div class=\"block\">This is an Object property where the "
+                + "Object is a single <code>List&lt;T&gt;</code>.</div>\n"
+                + "<dl>\n"
+                + "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+                + "<dd><a href=\"../pkg/MyClassT.html#getList--\">"
+                + "<code>getList()</code></a>, \n"
+                + "<a href=\"../pkg/MyClassT.html#setList-java.util.List-\">"
+                + "<code>setList(List)</code></a></dd>\n"
+                + "</dl>"
+        );
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/pkg/MyClass.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 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.
+ */
+
+package pkg;
+
+/**
+ * Test program for javadoc properties.
+ */
+public class MyClass {
+
+    private SimpleObjectProperty<MyObj> good
+            = new SimpleObjectProperty<MyObj>();
+
+    /**
+     * This is an Object property where the Object is a single Object.
+     *
+     * @return the good
+     */
+    public final ObjectProperty<MyObj> goodProperty() {
+        return good;
+    }
+
+    public final void setGood(MyObj good) {
+    }
+
+    public final MyObj getGood() {
+        return good.get();
+    }
+
+
+    private SimpleObjectProperty<MyObj[]> bad
+            = new SimpleObjectProperty<MyObj[]>();
+
+    /**
+     * This is an Object property where the Object is an array.
+     *
+     * @return the bad
+     */
+    public final ObjectProperty<MyObj[]> badProperty() {
+        return bad;
+    }
+
+    public final void setBad(MyObj[] bad) {
+    }
+
+    public final MyObj[] getBad() {
+        return bad.get();
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/pkg/MyClassT.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,32 @@
+package pkg;
+
+import java.util.List;
+
+//import javafx.beans.property.*;
+
+/**
+ * Test program for javadoc properties.
+ */
+public class MyClassT<T> {
+
+    private SimpleObjectProperty<List<T>> list
+            = new SimpleObjectProperty<List<T>>();
+
+    /**
+     * This is an Object property where the Object is a single {@code List<T>}.
+     *
+     * @return the list
+     */
+    public final ObjectProperty<List<T>> listProperty() {
+        return list;
+    }
+
+    public final void setList(List<T> list) {
+    }
+
+    public final List<T> getList() {
+        return list.get();
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/pkg/MyObj.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 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.
+ */
+
+package pkg;
+
+public class MyObj {
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/pkg/ObjectProperty.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 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.
+ */
+
+package pkg;
+
+public class ObjectProperty<T> { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testProperty/pkg/SimpleObjectProperty.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 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.
+ */
+
+package pkg;
+
+public class SimpleObjectProperty<T> { }
+
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -61,22 +61,7 @@
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
                 + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>,"
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
-                + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})",
-                "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>",
-                "<a href=\"../pkg/ContainerSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContainerSynthDoc</a>("
-                + ""
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>)",
-                "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a> "
-                + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
-                + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>");
+                + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})");
 
         checkOutput("pkg/D.html", true,
                 "<a href=\"../pkg/RegDoc.html\" title=\"annotation in pkg\">@RegDoc</a>"
@@ -88,7 +73,8 @@
                 "<a href=\"../pkg/NonSynthDocContainer.html\" "
                 + "title=\"annotation in pkg\">@NonSynthDocContainer</a>"
                 + "("
-                + "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)");
+                + "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>"
+                + "(<a href=\"../pkg/RegArryDoc.html#y--\">y</a>=1))");
 
         checkOutput("pkg1/C.html", true,
                 "<a href=\"../pkg1/RegContainerValDoc.html\" "
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,7 +28,6 @@
 @RegContainerDoc({@RegContaineeNotDoc,@RegContaineeNotDoc})
 @ContainerRegNotDoc({@RegContaineeDoc,@RegContaineeDoc})
 @RegContainerNotDoc({@RegContaineeNotDoc,@RegContaineeNotDoc})
-@ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc
 public class C {
 
     @ContainerSynthDoc({@ContaineeSynthDoc})
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -32,6 +32,6 @@
     @RegArryDoc(y={1,2})
     public void test2() {}
 
-    @NonSynthDocContainer({@RegArryDoc})
+    @NonSynthDocContainer({@RegArryDoc(y={1})})
     public void test3() {}
 }
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8141492 8071982 8141636 8147890 8166175 8168965
+ * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794
  * @summary Test the search feature of javadoc.
  * @author bpatel
  * @library ../lib
@@ -489,6 +489,8 @@
                 "camelCaseMatcher.test(item.l)",
                 "var secondaryresult = new Array();",
                 "function nestedName(e) {",
-                "function sortAndConcatResults(a1, a2) {");
+                "function sortAndConcatResults(a1, a2) {",
+                "if (exactMatcher.test(item.l)) {\n"
+                + "                        presult.unshift(item);");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug      8005091 8009686 8025633 8026567 6469562 8071982 8071984 8162363
+ * @bug      8005091 8009686 8025633 8026567 6469562 8071982 8071984 8162363 8175200
  * @summary  Make sure that type annotations are displayed correctly
  * @author   Bhavesh Patel
  * @library  ../lib
@@ -155,17 +155,17 @@
         checkOutput("typeannos/MtdDefaultScope.html", true,
                 "<pre>public&nbsp;&lt;T&gt;&nbsp;<a href=\"../typeannos/MRtnA.html\" "
                 + "title=\"annotation in typeannos\">@MRtnA</a> java.lang.String"
-                + "&nbsp;method()</pre>",
+                + "&nbsp;method&#8203;()</pre>",
 
                 // When JDK-8068737 is fixed, we should change the order
                 "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in typeannos\">"
                 + "@MRtnA</a> java.lang.String "
                 + "<a href=\"../typeannos/MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> [] "
                 + "<a href=\"../typeannos/MRtnA.html\" title=\"annotation in typeannos\">@MRtnA</a> []"
-                + "&nbsp;array2Deep()</pre>",
+                + "&nbsp;array2Deep&#8203;()</pre>",
 
                 "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in "
-                + "typeannos\">@MRtnA</a> java.lang.String[][]&nbsp;array2()</pre>");
+                + "typeannos\">@MRtnA</a> java.lang.String[][]&nbsp;array2&#8203;()</pre>");
 
         checkOutput("typeannos/MtdModifiedScoped.html", true,
                 "<pre>public final&nbsp;<a href=\"../typeannos/MtdParameterized.html\" "
@@ -177,25 +177,25 @@
                 + "String,<a href=\"../typeannos/MRtnB.html\" title=\"annotation in "
                 + "typeannos\">@MRtnB</a> java.lang.String&gt;,<a href=\"../typeannos/"
                 + "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java."
-                + "lang.String&gt;&nbsp;nestedMtdParameterized()</pre>");
+                + "lang.String&gt;&nbsp;nestedMtdParameterized&#8203;()</pre>");
 
         // Test for type annotations on method type parameters (MethodTypeParameters.java).
         checkOutput("typeannos/UnscopedUnmodified.html", true,
                 "<pre>&lt;K extends <a href=\"../typeannos/MTyParamA.html\" title=\""
                 + "annotation in typeannos\">@MTyParamA</a> java.lang.String&gt;"
-                + "&nbsp;void&nbsp;methodExtends()</pre>",
+                + "&nbsp;void&nbsp;methodExtends&#8203;()</pre>",
 
                 "<pre>&lt;K extends <a href=\"../typeannos/MTyParamA.html\" title=\""
                 + "annotation in typeannos\">@MTyParamA</a> <a href=\"../typeannos/"
                 + "MtdTyParameterized.html\" title=\"class in typeannos\">"
                 + "MtdTyParameterized</a>&lt;<a href=\"../typeannos/MTyParamB.html\" "
                 + "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String"
-                + "&gt;&gt;&nbsp;void&nbsp;nestedExtends()</pre>");
+                + "&gt;&gt;&nbsp;void&nbsp;nestedExtends&#8203;()</pre>");
 
         checkOutput("typeannos/PublicModifiedMethods.html", true,
                 "<pre>public final&nbsp;&lt;K extends <a href=\"../typeannos/"
                 + "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> "
-                + "java.lang.String&gt;&nbsp;void&nbsp;methodExtends()</pre>",
+                + "java.lang.String&gt;&nbsp;void&nbsp;methodExtends&#8203;()</pre>",
 
                 "<pre>public final&nbsp;&lt;K extends <a href=\"../typeannos/"
                 + "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> "
@@ -204,16 +204,16 @@
                 + "typeannos/MtdTyParameterized.html\" title=\"class in typeannos\">"
                 + "MtdTyParameterized</a>&lt;<a href=\"../typeannos/MTyParamB.html\" "
                 + "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String"
-                + "&gt;&gt;&nbsp;void&nbsp;dual()</pre>");
+                + "&gt;&gt;&nbsp;void&nbsp;dual&#8203;()</pre>");
 
         // Test for type annotations on parameters (Parameters.java).
         checkOutput("typeannos/Parameters.html", true,
-                "<pre>void&nbsp;unannotated(<a href=\"../typeannos/"
+                "<pre>void&nbsp;unannotated&#8203;(<a href=\"../typeannos/"
                 + "ParaParameterized.html\" title=\"class in typeannos\">"
                 + "ParaParameterized</a>&lt;java.lang.String,java.lang.String&gt;"
                 + "&nbsp;a)</pre>",
 
-                "<pre>void&nbsp;nestedParaParameterized(<a href=\"../typeannos/"
+                "<pre>void&nbsp;nestedParaParameterized&#8203;(<a href=\"../typeannos/"
                 + "ParaParameterized.html\" title=\"class in typeannos\">"
                 + "ParaParameterized</a>&lt;<a href=\"../typeannos/ParamA.html\" "
                 + "title=\"annotation in typeannos\">@ParamA</a> <a href=\"../"
@@ -226,7 +226,7 @@
                 + "</a> java.lang.String&gt;&nbsp;a)</pre>",
 
                 // When JDK-8068737 is fixed, we should change the order
-                "<pre>void&nbsp;array2Deep(<a href=\"../typeannos/ParamA.html\" "
+                "<pre>void&nbsp;array2Deep&#8203;(<a href=\"../typeannos/ParamA.html\" "
                 + "title=\"annotation in typeannos\">@ParamA</a> java.lang.String "
                 + "<a href=\"../typeannos/ParamB.html\" title=\"annotation in typeannos\">"
                 + "@ParamB</a> [] "
@@ -236,34 +236,34 @@
 
         // Test for type annotations on throws (Throws.java).
         checkOutput("typeannos/ThrDefaultUnmodified.html", true,
-                "<pre>void&nbsp;oneException()\n"
+                "<pre>void&nbsp;oneException&#8203;()\n"
                 + "           throws <a href=\"../typeannos/ThrA.html\" title=\""
                 + "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>",
 
-                "<pre>void&nbsp;twoExceptions()\n"
+                "<pre>void&nbsp;twoExceptions&#8203;()\n"
                 + "            throws <a href=\"../typeannos/ThrA.html\" title=\""
                 + "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException,\n"
                 + "                   <a href=\"../typeannos/ThrA.html\" title=\""
                 + "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>");
 
         checkOutput("typeannos/ThrPublicModified.html", true,
-                "<pre>public final&nbsp;void&nbsp;oneException(java.lang.String&nbsp;a)\n"
+                "<pre>public final&nbsp;void&nbsp;oneException&#8203;(java.lang.String&nbsp;a)\n"
                 + "                        throws <a href=\"../typeannos/ThrA.html\" "
                 + "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>",
 
-                "<pre>public final&nbsp;void&nbsp;twoExceptions(java.lang.String&nbsp;a)\n"
+                "<pre>public final&nbsp;void&nbsp;twoExceptions&#8203;(java.lang.String&nbsp;a)\n"
                 + "                         throws <a href=\"../typeannos/ThrA.html\" "
                 + "title=\"annotation in typeannos\">@ThrA</a> java.lang.RuntimeException,\n"
                 + "                                <a href=\"../typeannos/ThrA.html\" "
                 + "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>");
 
         checkOutput("typeannos/ThrWithValue.html", true,
-                "<pre>void&nbsp;oneException()\n"
+                "<pre>void&nbsp;oneException&#8203;()\n"
                 + "           throws <a href=\"../typeannos/ThrB.html\" title=\""
                 + "annotation in typeannos\">@ThrB</a>("
                 + "\"m\") java.lang.Exception</pre>",
 
-                "<pre>void&nbsp;twoExceptions()\n"
+                "<pre>void&nbsp;twoExceptions&#8203;()\n"
                 + "            throws <a href=\"../typeannos/ThrB.html\" title=\""
                 + "annotation in typeannos\">@ThrB</a>("
                 + "\"m\") java.lang.RuntimeException,\n"
@@ -275,12 +275,12 @@
                 "<pre>&lt;K,<a href=\"../typeannos/TyParaA.html\" title=\"annotation in typeannos\">"
                 + "@TyParaA</a> V extends <a href=\"../typeannos/TyParaA.html\" "
                 + "title=\"annotation in typeannos\">@TyParaA</a> "
-                + "java.lang.String&gt;&nbsp;void&nbsp;secondAnnotated()</pre>"
+                + "java.lang.String&gt;&nbsp;void&nbsp;secondAnnotated&#8203;()</pre>"
         );
 
         // Test for type annotations on wildcard type (Wildcards.java).
         checkOutput("typeannos/BoundTest.html", true,
-                "<pre>void&nbsp;wcExtends(<a href=\"../typeannos/MyList.html\" "
+                "<pre>void&nbsp;wcExtends&#8203;(<a href=\"../typeannos/MyList.html\" "
                 + "title=\"class in typeannos\">MyList</a>&lt;? extends <a href=\""
                 + "../typeannos/WldA.html\" title=\"annotation in typeannos\">@WldA"
                 + "</a> java.lang.String&gt;&nbsp;l)</pre>",
@@ -288,10 +288,10 @@
                 "<pre><a href=\"../typeannos/MyList.html\" title=\"class in "
                 + "typeannos\">MyList</a>&lt;? super <a href=\"../typeannos/WldA.html\" "
                 + "title=\"annotation in typeannos\">@WldA</a> java.lang.String&gt;"
-                + "&nbsp;returnWcSuper()</pre>");
+                + "&nbsp;returnWcSuper&#8203;()</pre>");
 
         checkOutput("typeannos/BoundWithValue.html", true,
-                "<pre>void&nbsp;wcSuper(<a href=\"../typeannos/MyList.html\" title=\""
+                "<pre>void&nbsp;wcSuper&#8203;(<a href=\"../typeannos/MyList.html\" title=\""
                 + "class in typeannos\">MyList</a>&lt;? super <a href=\"../typeannos/"
                 + "WldB.html\" title=\"annotation in typeannos\">@WldB</a>("
                 + "\"m\") java.lang."
@@ -301,41 +301,41 @@
                 + "typeannos\">MyList</a>&lt;? extends <a href=\"../typeannos/WldB."
                 + "html\" title=\"annotation in typeannos\">@WldB</a>("
                 + "\"m\") java.lang.String"
-                + "&gt;&nbsp;returnWcExtends()</pre>");
+                + "&gt;&nbsp;returnWcExtends&#8203;()</pre>");
 
         // Test for receiver annotations (Receivers.java).
         checkOutput("typeannos/DefaultUnmodified.html", true,
-                "<pre>void&nbsp;withException(<a href=\"../typeannos/RcvrA.html\" "
+                "<pre>void&nbsp;withException&#8203;(<a href=\"../typeannos/RcvrA.html\" "
                 + "title=\"annotation in typeannos\">@RcvrA</a>&nbsp;"
                 + "DefaultUnmodified&nbsp;this)\n"
                 + "            throws java."
                 + "lang.Exception</pre>",
 
-                "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrA."
+                "<pre>java.lang.String&nbsp;nonVoid&#8203;(<a href=\"../typeannos/RcvrA."
                 + "html\" title=\"annotation in typeannos\">@RcvrA</a> <a href=\"../"
                 + "typeannos/RcvrB.html\" title=\"annotation in typeannos\">@RcvrB"
                 + "</a>(\"m\")"
                 + "&nbsp;DefaultUnmodified&nbsp;this)</pre>",
 
-                "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept("
+                "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept&#8203;("
                 + "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in "
                 + "typeannos\">@RcvrA</a>&nbsp;DefaultUnmodified&nbsp;this,\n"
                 + "                                           T&nbsp;r)\n"
                 + "                                    throws java.lang.Exception</pre>");
 
         checkOutput("typeannos/PublicModified.html", true,
-                "<pre>public final&nbsp;java.lang.String&nbsp;nonVoid(<a href=\""
+                "<pre>public final&nbsp;java.lang.String&nbsp;nonVoid&#8203;(<a href=\""
                 + "../typeannos/RcvrA.html\" title=\"annotation in typeannos\">"
                 + "@RcvrA</a>&nbsp;PublicModified&nbsp;this)</pre>",
 
                 "<pre>public final&nbsp;&lt;T extends java.lang.Runnable&gt;&nbsp;"
-                + "void&nbsp;accept(<a href=\"../typeannos/RcvrA.html\" title=\""
+                + "void&nbsp;accept&#8203;(<a href=\"../typeannos/RcvrA.html\" title=\""
                 + "annotation in typeannos\">@RcvrA</a>&nbsp;PublicModified&nbsp;this,\n"
                 + "                                                        T&nbsp;r)\n"
                 + "                                                 throws java.lang.Exception</pre>");
 
         checkOutput("typeannos/WithValue.html", true,
-                "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept("
+                "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept&#8203;("
                 + "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in "
                 + "typeannos\">@RcvrB</a>("
                 + "\"m\")&nbsp;WithValue&nbsp;this,\n"
@@ -343,17 +343,17 @@
                 + "                                    throws java.lang.Exception</pre>");
 
         checkOutput("typeannos/WithFinal.html", true,
-                "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB."
-                + "html\" title=\"annotation in typeannos\">@RcvrB</a>("
-                + "\"m\")&nbsp;WithFinal"
-                + "&nbsp;this)</pre>");
+                "<pre>java.lang.String&nbsp;nonVoid&#8203;(<a href=\"../typeannos/RcvrB.html\" "
+                + "title=\"annotation in typeannos\">@RcvrB</a>(\"m\") "
+                + "<a href=\"../typeannos/WithFinal.html\" title=\"class in typeannos\">"
+                + "WithFinal</a>&nbsp;afield)</pre>");
 
         checkOutput("typeannos/WithBody.html", true,
-                "<pre>void&nbsp;field(<a href=\"../typeannos/RcvrA.html\" title=\""
+                "<pre>void&nbsp;field&#8203;(<a href=\"../typeannos/RcvrA.html\" title=\""
                 + "annotation in typeannos\">@RcvrA</a>&nbsp;WithBody&nbsp;this)</pre>");
 
         checkOutput("typeannos/Generic2.html", true,
-                "<pre>void&nbsp;test2(<a href=\"../typeannos/RcvrA.html\" title=\""
+                "<pre>void&nbsp;test2&#8203;(<a href=\"../typeannos/RcvrA.html\" title=\""
                 + "annotation in typeannos\">@RcvrA</a>&nbsp;Generic2&lt;X&gt;&nbsp;this)</pre>");
 
 
@@ -396,7 +396,7 @@
                 + "\"../typeannos/RepConstructorB.html\" title=\"annotation in typeannos"
                 + "\">@RepConstructorB</a> <a href=\"../typeannos/RepConstructorB.html"
                 + "\" title=\"annotation in typeannos\">@RepConstructorB</a>\n"
-                + "RepeatingOnConstructor()</pre>",
+                + "RepeatingOnConstructor&#8203;()</pre>",
 
                 "<pre><a href=\"../typeannos/RepConstructorA.html\" title=\"annotation in typeannos"
                 + "\">@RepConstructorA</a> <a href=\"../typeannos/RepConstructorA.html"
@@ -404,7 +404,7 @@
                 + "\"../typeannos/RepConstructorB.html\" title=\"annotation in typeannos"
                 + "\">@RepConstructorB</a> <a href=\"../typeannos/RepConstructorB.html"
                 + "\" title=\"annotation in typeannos\">@RepConstructorB</a>\n"
-                + "RepeatingOnConstructor(int&nbsp;i,\n                       int&nbsp;j)</pre>",
+                + "RepeatingOnConstructor&#8203;(int&nbsp;i,\n                       int&nbsp;j)</pre>",
 
                 "<pre><a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos"
                 + "\">@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html"
@@ -412,10 +412,10 @@
                 + "<a href=\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos"
                 + "\">@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html"
                 + "\" title=\"annotation in typeannos\">@RepAllContextsB</a>\n"
-                + "RepeatingOnConstructor(int&nbsp;i,\n                       int&nbsp;j,\n"
+                + "RepeatingOnConstructor&#8203;(int&nbsp;i,\n                       int&nbsp;j,\n"
                 + "                       int&nbsp;k)</pre>",
 
-                "<pre>RepeatingOnConstructor(<a href=\"../typeannos/RepParameterA.html"
+                "<pre>RepeatingOnConstructor&#8203;(<a href=\"../typeannos/RepParameterA.html"
                 + "\" title=\"annotation in typeannos\">@RepParameterA</a> <a href="
                 + "\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos"
                 + "\">@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html"
@@ -440,7 +440,7 @@
         checkOutput("typeannos/RepeatingOnConstructor.Inner.html", true,
                 "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnConstructor.Inner.html"
                 + "#Inner-java.lang.String-java.lang.String...-\">Inner</a></span>"
-                + "(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
+                + "&#8203;(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
                 + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
                 + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
@@ -448,7 +448,7 @@
                 + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseB</a> ...&nbsp;vararg)</code>",
 
-                "Inner(<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                "Inner&#8203;(<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
                 + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
                 + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
@@ -574,7 +574,7 @@
         checkOutput("typeannos/RepeatingOnMethod.html", true,
                 "<code>(package private) java.lang.String</code></td>\n<th class=\"colSecond\" scope=\"row\">"
                 + "<code><span class=\"memberNameLink\"><a href="
-                + "\"../typeannos/RepeatingOnMethod.html#test1--\">test1</a></span>()</code>",
+                + "\"../typeannos/RepeatingOnMethod.html#test1--\">test1</a></span>&#8203;()</code>",
 
                 "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" "
                 + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
@@ -584,7 +584,7 @@
                 + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String</code>"
                 + "</td>\n<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../typeannos/RepeatingOnMethod.html#test2--\">test2</a>"
-                + "</span>()</code>",
+                + "</span>&#8203;()</code>",
 
                 "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" "
                 + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
@@ -594,7 +594,7 @@
                 + "title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String</code>"
                 + "</td>\n<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                 + "<a href=\"../typeannos/RepeatingOnMethod.html#test3--\">test3</a>"
-                + "</span>()</code>",
+                + "</span>&#8203;()</code>",
 
                 "<code>(package private) <a href=\"../typeannos/RepAllContextsA.html\" "
                 + "title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
@@ -604,11 +604,11 @@
                 + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
                 + "@RepAllContextsB</a> java.lang.String</code></td>\n<th class=\"colSecond\" scope=\"row\">"
                 + "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnMethod.html"
-                + "#test4--\">test4</a></span>()</code>",
+                + "#test4--\">test4</a></span>&#8203;()</code>",
 
                 "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnMethod.html"
                 + "#test5-java.lang.String-java.lang.String...-\">test5</a></span>"
-                + "(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
+                + "&#8203;(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
                 + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
                 + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
@@ -621,13 +621,13 @@
                 + "\"annotation in typeannos\">@RepMethodA</a>\n<a href=\"../typeannos/RepMethodB.html\""
                 + " title=\"annotation in typeannos\">@RepMethodB</a> <a href="
                 + "\"../typeannos/RepMethodB.html\" title=\"annotation in typeannos\">"
-                + "@RepMethodB</a>\njava.lang.String&nbsp;test1()",
+                + "@RepMethodB</a>\njava.lang.String&nbsp;test1&#8203;()",
 
                 "<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
                 + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" "
                 + "title=\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
-                + "title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test2()",
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test2&#8203;()",
 
                 "<a href=\"../typeannos/RepMethodA.html\" title=\"annotation in typeannos\">"
                 + "@RepMethodA</a> <a href=\"../typeannos/RepMethodA.html\" title="
@@ -639,7 +639,7 @@
                 + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
                 + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
-                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test3()",
+                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test3&#8203;()",
 
                 "<a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
                 + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html\" "
@@ -652,9 +652,9 @@
                 + "title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
                 + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
                 + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html\" "
-                + "title=\"annotation in typeannos\">@RepAllContextsB</a> java.lang.String&nbsp;test4()",
+                + "title=\"annotation in typeannos\">@RepAllContextsB</a> java.lang.String&nbsp;test4&#8203;()",
 
-                "java.lang.String&nbsp;test5(<a href=\"../typeannos/RepTypeUseA.html\" "
+                "java.lang.String&nbsp;test5&#8203;(<a href=\"../typeannos/RepTypeUseA.html\" "
                 + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
                 + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
@@ -684,12 +684,12 @@
                 "<code>(package private) &lt;T&gt;&nbsp;java.lang.String</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href="
                 + "\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
-                + "genericMethod-T-\">genericMethod</a></span>(T&nbsp;t)</code>",
+                + "genericMethod-T-\">genericMethod</a></span>&#8203;(T&nbsp;t)</code>",
 
                 "<code>(package private) &lt;T&gt;&nbsp;java.lang.String</code></td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href="
                 + "\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
-                + "genericMethod2-T-\">genericMethod2</a></span>(<a href=\"../typeannos/RepTypeUseA.html"
+                + "genericMethod2-T-\">genericMethod2</a></span>&#8203;(<a href=\"../typeannos/RepTypeUseA.html"
                 + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
                 + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
                 + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
@@ -697,9 +697,9 @@
 
                 "<code>(package private) java.lang.String</code></td>\n<th class=\"colSecond\" scope=\"row\"><code>"
                 + "<span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
-                + "test--\">test</a></span>()</code>",
+                + "test--\">test</a></span>&#8203;()</code>",
 
-                "java.lang.String&nbsp;test(<a href=\"../typeannos/RepTypeUseA.html\" "
+                "java.lang.String&nbsp;test&#8203;(<a href=\"../typeannos/RepTypeUseA.html\" "
                 + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
                 + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
                 + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
@@ -718,6 +718,6 @@
                 + "\"annotation in typeannos\">@RepMethodA</a>\n<a href=\"../typeannos/RepMethodB.html"
                 + "\" title=\"annotation in typeannos\">@RepMethodB</a> <a href="
                 + "\"../typeannos/RepMethodB.html\" title=\"annotation in typeannos\">"
-                + "@RepMethodB</a>\nvoid&nbsp;test()");
+                + "@RepMethodB</a>\nvoid&nbsp;test&#8203;()");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -53,11 +53,12 @@
 }
 
 class WithFinal {
-    void plain(final @RcvrB("m") WithFinal this) { }
-    <T> void generic(final @RcvrB("m") WithFinal this) { }
-    void withException(final @RcvrB("m") WithFinal this) throws Exception { }
-    String nonVoid(final @RcvrB("m") WithFinal this) { return null; }
-    <T extends Runnable> void accept(final @RcvrB("m") WithFinal this, T r) throws Exception { }
+    WithFinal afield;
+    void plain(final @RcvrB("m") WithFinal afield) { }
+    <T> void generic(final @RcvrB("m") WithFinal afield) { }
+    void withException(final @RcvrB("m") WithFinal afield) throws Exception { }
+    String nonVoid(final @RcvrB("m") WithFinal afield) { return null; }
+    <T extends Runnable> void accept(final @RcvrB("m") WithFinal afield, T r) throws Exception { }
 }
 
 class WithBody {
--- a/langtools/test/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854 8071982 8162363
+ * @bug 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854 8071982 8162363 8175200
  * @summary A simple test to ensure class-use files are correct.
  * @author jamieh
  * @library ../lib
@@ -134,7 +134,7 @@
             "<td class=\"colFirst\"><code>void</code></td>\n<th class=\"colSecond\" scope=\"row\"><span class="
             + "\"typeNameLabel\">C1.</span><code><span class=\"memberNameLink\">"
             + "<a href=\"../../pkg1/C1.html#methodInC1ThrowsThrowable--\">methodInC1ThrowsThrowable"
-            + "</a></span>()</code></th>"
+            + "</a></span>&#8203;()</code></th>"
         );
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUserTaglet/InfoTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 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.
+ */
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Element;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Taglet;
+import static jdk.javadoc.doclet.Taglet.Location.*;
+
+import com.sun.source.doctree.DocTree;
+
+/**
+ * A taglet to test access to a taglet's context.
+ */
+public class InfoTaglet implements Taglet {
+    private DocletEnvironment env;
+    private Doclet doclet;
+
+    @Override
+    public void init(DocletEnvironment env, Doclet doclet) {
+        this.env = env;
+        this.doclet = doclet;
+    }
+
+    @Override
+    public Set<Location> getAllowedLocations() {
+        return EnumSet.of(TYPE);
+    }
+
+    @Override
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    @Override
+    public String getName() {
+        return "info";
+    }
+
+    @Override
+    public String toString(List<? extends DocTree> tags, Element element) {
+        // The content lines below are primarily to help verify the element
+        // and the values passed to init.
+        return "<dt>"
+                +"<span class=\"simpleTagLabel\">Info:</span>\n"
+                + "</dt>"
+                + "<dd>"
+                + "<ul>\n"
+                + "<li>Element: " + element.getKind() + " " + element.getSimpleName() + "\n"
+                + "<li>Element supertypes: " +
+                        env.getTypeUtils().directSupertypes(element.asType()) + "\n"
+                + "<li>Doclet: " + doclet.getClass() + "\n"
+                + "</ul>\n"
+                + "</dd>";
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUserTaglet/TestUserTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 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      8176836
+ * @summary  Provide Taglet with context
+ * @library  ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build    JavadocTester InfoTaglet
+ * @run main TestUserTaglet
+ */
+
+public class TestUserTaglet extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestUserTaglet tester = new TestUserTaglet();
+        tester.runTests();
+    }
+
+    @Test
+    void test() {
+        javadoc("-d", "out",
+                "-sourcepath", testSrc,
+                "-tagletpath", System.getProperty("test.class.path"),
+                "-taglet", "InfoTaglet",
+                "pkg");
+        checkExit(Exit.OK);
+
+        // The following checks verify that information was successfully
+        // derived from the context information available to the taglet.
+        checkOutput("pkg/C.html", true,
+            "<li>Element: CLASS C",
+            "<li>Element supertypes: [java.lang.Object]",
+            "<li>Doclet: class jdk.javadoc.internal.doclets.formats.html.HtmlDoclet"
+        );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUserTaglet/pkg/C.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 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.
+ */
+
+package pkg;
+
+/** @info */
+public class C { }
+
--- a/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,6 +40,7 @@
 import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import javax.lang.model.element.Element;
 
 import com.sun.javadoc.Tag;
 import com.sun.source.doctree.DocTree;
@@ -186,7 +187,7 @@
                 "-tagletpath",
                 testClasses,
                 testSrc.toString());
-        Task.Result tr = task.run(Task.Expect.FAIL, 1);
+        Task.Result tr = task.run(Task.Expect.FAIL, 1).writeAll();
         //Task.Result tr = task.run();
         List<String> out = tr.getOutputLines(Task.OutputKind.STDOUT);
         List<String> err = tr.getOutputLines(Task.OutputKind.STDERR);
@@ -358,7 +359,7 @@
         }
 
         @Override
-        public String toString(List<? extends DocTree> tags) {
+        public String toString(List<? extends DocTree> tags, Element element) {
             return tags.toString();
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/IgnoreSourceErrors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 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 8175219
+ * @summary test --ignore-errors works correctly
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main IgnoreSourceErrors
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.Arrays;
+
+import toolbox.*;
+import toolbox.Task.*;
+
+/**
+ * Dummy javadoc comment.
+ */
+public class IgnoreSourceErrors  extends TestRunner {
+
+    final ToolBox tb;
+    final Path testSrc;
+
+    public IgnoreSourceErrors() throws IOException {
+        super(System.err);
+        tb = new ToolBox();
+        testSrc = Paths.get("Foo.java");
+        emitSample(testSrc);
+    }
+
+    public static void main(String... args) throws Exception {
+        new IgnoreSourceErrors().runTests();
+    }
+
+    @Test
+    public void runIgnoreErrorsOffByDefault() throws Exception {
+        JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE);
+        task.options(testSrc.toString());
+        Task.Result result = task.run(Expect.FAIL);
+        String out = result.getOutput(OutputKind.DIRECT);
+        if (!out.contains("modifier static not allowed here")) {
+            throw new Exception("expected string not found \'modifier static not allowed here\'");
+        }
+    }
+
+    @Test
+    public void runIgnoreErrorsOn() throws Exception {
+        JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE);
+        task.options("--ignore-source-errors", testSrc.toString());
+        Task.Result result = task.run(Expect.SUCCESS);
+        String out = result.getOutput(OutputKind.DIRECT);
+        if (!out.contains("modifier static not allowed here")) {
+            throw new Exception("expected string not found \'modifier static not allowed here\'");
+        }
+    }
+
+    void emitSample(Path file) throws IOException {
+        String[] contents = {
+            "/** A java file with errors */",
+            "public static class Foo {}"
+        };
+        Files.write(file, Arrays.asList(contents), StandardOpenOption.CREATE);
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -47,7 +47,7 @@
     }
 
     void run() {
-        doRunTest(OK, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
+        doRunTest(ERROR, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
         doRunTest(OK, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
         doRunTest(CMDERR, out -> true, "--release", "7", "-source", "7");
         doRunTest(CMDERR, out -> true, "--release", "7", "-bootclasspath", "any");
--- a/langtools/test/jdk/javadoc/tool/T6551367.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/T6551367.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -37,8 +37,6 @@
 
 import jdk.javadoc.doclet.DocletEnvironment;
 
-import static jdk.javadoc.internal.tool.Main.execute;
-
 public class T6551367 {
     public T6551367() {}
     public boolean run(DocletEnvironment root) {
@@ -59,7 +57,7 @@
                 destDir.getAbsolutePath()
             };
 
-            int rc = execute(array);
+            int rc = jdk.javadoc.internal.tool.Main.execute(array);
             if (rc != 0)
                 throw new Error("unexpected exit from javadoc: " + rc);
         }
--- a/langtools/test/jdk/javadoc/tool/api/basic/taglets/UnderlineTaglet.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/api/basic/taglets/UnderlineTaglet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,44 +1,30 @@
 /*
  * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * -Redistributions of source code must retain the above copyright
- *  notice, this list of conditions and the following disclaimer.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * -Redistribution in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in
- *  the documentation and/or other materials provided with the
- *  distribution.
- *
- * Neither the name of Oracle nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 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 software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
- * DAMAGES OR LIABILITIES  SUFFERED BY LICENSEE AS A RESULT OF OR
- * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
- * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
- * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
- * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
- * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
- * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ * 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 acknowledge that Software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
+ * 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.
  */
 
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
+import javax.lang.model.element.Element;
 
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.TextTree;
@@ -88,8 +74,9 @@
      * Given the <code>DocTree</code> representation of this custom
      * tag, return its string representation.
      * @param tags the list of trees representing of this custom tag.
+     * @param element the declaration to which the enclosing comment belongs
      */
-    public String toString(List<? extends DocTree> tags) {
+    public String toString(List<? extends DocTree> tags, Element element) {
         return "<u>" + getText(tags.get(0)) + "</u>";
     }
 
--- a/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -34,7 +34,7 @@
         String srcpath = System.getProperty("test.src", ".");
 
         if (jdk.javadoc.internal.tool.Main.execute(
-                new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0)
-            throw new Error("Javadoc encountered warnings or errors.");
+                new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) == 0)
+            throw new Error("Javadoc passed unexpectedly");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/CommandLineFiles.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 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 8176539
+ * @summary Test use case when all java files are listed
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main CommandLineFiles
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import toolbox.*;
+
+public class CommandLineFiles extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new CommandLineFiles().runTests();
+    }
+
+    @Test
+    public void testExplicitJavaFiles(Path base) throws Exception {
+        Path src = Paths.get(base.toString(), "src");
+        Path mpath = Paths.get(src. toString(), "m");
+
+        tb.writeJavaFiles(mpath,
+                "module m { exports p; }",
+                "package p; public class C { }");
+
+        List<String> cmdList = new ArrayList<>();
+        cmdList.add("--source-path");
+        cmdList.add(mpath.toString());
+        Arrays.asList(tb.findJavaFiles(src)).stream()
+                .map(Path::toString)
+                .collect(Collectors.toCollection(() -> cmdList));
+        execTask(cmdList.toArray(new String[cmdList.size()]));
+        assertMessageNotPresent("warning:");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/MissingSourceModules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 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 8176481
+ * @summary Tests behavior of the tool, when modules are present as
+ *          binaries.
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main MissingSourceModules
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.*;
+
+public class MissingSourceModules extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new MissingSourceModules().runTests();
+    }
+
+    @Test
+    public void testExplicitBinaryModuleOnModulePath(Path base) throws Exception {
+        Path modulePath = base.resolve("modules");
+
+        ModuleBuilder ma = new ModuleBuilder(tb, "ma");
+        ma.comment("Module ma.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .classes("package pkg1.pkg2; /** Class B */ public class B { }")
+                .build(modulePath);
+
+        execNegativeTask("--module-path", modulePath.toString(),
+                "--module", "ma");
+        assertMessagePresent("module ma not found.");
+    }
+
+    @Test
+    public void testExplicitBinaryModuleOnLegacyPaths(Path base) throws Exception {
+        Path modulePath = base.resolve("modules");
+
+        ModuleBuilder ma = new ModuleBuilder(tb, "ma");
+        ma.comment("Module ma.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .classes("package pkg1.pkg2; /** Class B */ public class B { }")
+                .build(modulePath);
+
+        Path mPath = Paths.get(modulePath.toString(), "ma");
+        execNegativeTask("--source-path", mPath.toString(),
+                "--module", "ma");
+        assertMessagePresent("module ma not found.");
+
+        execNegativeTask("--class-path", mPath.toString(),
+                "--module", "ma");
+        assertMessagePresent("module ma not found.");
+    }
+
+    @Test
+    public void testImplicitBinaryRequiresModule(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path modulePath = base.resolve("modules");
+
+        ModuleBuilder mb = new ModuleBuilder(tb, "mb");
+        mb.comment("Module mb.")
+                .exports("pkgb")
+                .classes("package pkgb; /** Class A */ public class A { }")
+                .build(modulePath);
+
+        ModuleBuilder ma = new ModuleBuilder(tb, "ma");
+        ma.comment("Module ma.")
+                .exports("pkga")
+                .requires("mb", modulePath)
+                .classes("package pkga; /** Class A */ public class A { }")
+                .write(src);
+
+        execTask("--module-path", modulePath.toString(),
+                "--module-source-path", src.toString(),
+                "--expand-requires", "all",
+                "--module", "ma");
+        assertMessagePresent("module mb not found.");
+    }
+
+    @Test
+    public void testImplicitBinaryTransitiveModule(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path modulePath = base.resolve("modules");
+
+        ModuleBuilder mb = new ModuleBuilder(tb, "mb");
+        mb.comment("Module mb.")
+                .exports("pkgb")
+                .classes("package pkgb; /** Class A */ public class A { }")
+                .build(modulePath);
+
+        ModuleBuilder ma = new ModuleBuilder(tb, "ma");
+        ma.comment("Module ma.")
+                .exports("pkga")
+                .requiresTransitive("mb", modulePath)
+                .classes("package pkga; /** Class A */ public class A { }")
+                .write(src);
+
+        execTask("--module-path", modulePath.toString(),
+                "--module-source-path", src.toString(),
+                "--expand-requires", "transitive",
+                "--module", "ma");
+        assertMessagePresent("module mb not found.");
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
-import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
@@ -158,6 +158,12 @@
         }
     }
 
+    void checkTypesSelected(String... args) throws Exception {
+        for (String arg : args) {
+            checkDocletOutputPresent("Selected", ElementKind.CLASS, arg);
+        }
+    }
+
     void checkMembersSelected(String... args) throws Exception {
         for (String arg : args) {
             checkDocletOutputPresent("Selected", ElementKind.METHOD, arg);
@@ -180,11 +186,11 @@
         assertPresent(regex, STDOUT);
     }
 
-    void assertErrorPresent(String regex) throws Exception {
+    void assertMessagePresent(String regex) throws Exception {
         assertPresent(regex, Task.OutputKind.DIRECT);
     }
 
-    void assertErrorNotPresent(String regex) throws Exception {
+    void assertMessageNotPresent(String regex) throws Exception {
         assertNotPresent(regex, Task.OutputKind.DIRECT);
     }
 
@@ -280,6 +286,17 @@
         StringWriter sw = new StringWriter();
         PrintWriter ps = new PrintWriter(sw);
 
+        DocletEnvironment docEnv = null;
+
+        boolean hasDocComments = false;
+
+        String hasDocComments(Element e) {
+            String comment = docEnv.getElementUtils().getDocComment(e);
+            return comment != null && !comment.isEmpty()
+                    ? "hasDocComments"
+                    : "noDocComments";
+        }
+
         // csv style output, for simple regex verification
         void printDataSet(String header, Set<? extends Element> set) {
             for (Element e : set) {
@@ -290,7 +307,12 @@
                         ps.print(FS);
                         ps.print(e.getKind());
                         ps.print(FS);
-                        ps.println(e.getQualifiedName());
+                        ps.print(e.getQualifiedName());
+                        if (hasDocComments) {
+                            ps.print(FS);
+                            ps.print(hasDocComments(e));
+                        }
+                        ps.println();
                         return null;
                     }
 
@@ -299,7 +321,12 @@
                         ps.print(FS);
                         ps.print(e.getKind());
                         ps.print(FS);
-                        ps.println(e.getQualifiedName());
+                        ps.print(e.getQualifiedName());
+                        if (hasDocComments) {
+                            ps.print(FS);
+                            ps.print(hasDocComments(e));
+                        }
+                        ps.println();
                         return null;
                     }
 
@@ -308,7 +335,12 @@
                         ps.print(FS);
                         ps.print(ElementKind.CLASS);
                         ps.print(FS);
-                        ps.println(e.getQualifiedName());
+                        ps.print(e.getQualifiedName());
+                        if (hasDocComments) {
+                            ps.print(FS);
+                            ps.print(hasDocComments(e));
+                        }
+                        ps.println();
                         return null;
                     }
 
@@ -338,7 +370,12 @@
                         ps.print(FS);
                         ps.print(fqn);
                         ps.print(".");
-                        ps.println(e.getSimpleName());
+                        ps.print(e.getSimpleName());
+                        if (hasDocComments) {
+                            ps.print(FS);
+                            ps.print(hasDocComments(e));
+                        }
+                        ps.println();
                         return null;
                     }
                 }.visit(e);
@@ -347,6 +384,7 @@
 
         @Override
         public boolean run(DocletEnvironment docenv) {
+            this.docEnv = docenv;
             ps.println("ModuleMode" + FS + docenv.getModuleMode());
             printDataSet("Specified", docenv.getSpecifiedElements());
             printDataSet("Included", docenv.getIncludedElements());
@@ -369,7 +407,9 @@
                 addEnclosedElements(docenv, result, me);
             }
             for (PackageElement pe : ElementFilter.packagesIn(elements)) {
-                addEnclosedElements(docenv, result, docenv.getElementUtils().getModuleOf(pe));
+                ModuleElement mdle = docenv.getElementUtils().getModuleOf(pe);
+                if (mdle != null)
+                    addEnclosedElements(docenv, result, mdle);
                 addEnclosedElements(docenv, result, pe);
             }
             for (TypeElement te : ElementFilter.typesIn(elements)) {
@@ -390,7 +430,45 @@
 
         @Override
         public Set<Doclet.Option> getSupportedOptions() {
-            return Collections.emptySet();
+            Option[] options = {
+                new Option() {
+                    private final List<String> someOption = Arrays.asList(
+                            "-hasDocComments"
+                    );
+
+                    @Override
+                    public int getArgumentCount() {
+                        return 0;
+                    }
+
+                    @Override
+                    public String getDescription() {
+                        return "print disposition of doc comments on an element";
+                    }
+
+                    @Override
+                    public Option.Kind getKind() {
+                        return Option.Kind.STANDARD;
+                    }
+
+                    @Override
+                    public List<String> getNames() {
+                        return someOption;
+                    }
+
+                    @Override
+                    public String getParameters() {
+                        return "flag";
+                    }
+
+                    @Override
+                    public boolean process(String opt, List<String> arguments) {
+                        hasDocComments = true;
+                        return true;
+                    }
+                }
+            };
+            return new HashSet<>(Arrays.asList(options));
         }
 
         @Override
--- a/langtools/test/jdk/javadoc/tool/modules/Modules.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/modules/Modules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8159305 8166127 8175860
+ * @bug 8159305 8166127 8175860 8176481
  * @summary Tests primarily the module graph computations.
  * @modules
  *      jdk.javadoc/jdk.javadoc.internal.api
@@ -111,8 +111,8 @@
         execNegativeTask("--source-path", mod.toString(),
                 javafile.toString());
 
-        assertErrorPresent("error: cannot access module-info");
-        assertErrorNotPresent("error - fatal error encountered");
+        assertMessagePresent("error: cannot access module-info");
+        assertMessageNotPresent("error - fatal error encountered");
 
     }
 
@@ -174,7 +174,7 @@
         // no module path
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "m2");
-        assertErrorPresent("error: module not found: m1");
+        assertMessagePresent("error: module not found: m1");
     }
 
     @Test
@@ -213,7 +213,7 @@
         execNegativeTask("--module-source-path", src.toString(),
                 "--module-path", modulePath.toString(),
                 "--module", "m2");
-        assertErrorPresent("error: cannot find symbol");
+        assertMessagePresent("error: cannot find symbol");
 
         // dependency from module path
         ModuleBuilder mb3 = new ModuleBuilder(tb, "m3");
@@ -226,7 +226,7 @@
                 "--module-path", modulePath.toString(),
                 "--upgrade-module-path", upgradePath.toString(),
                 "--module", "m3");
-        assertErrorPresent("Z.java:1: error: cannot find symbol");
+        assertMessagePresent("Z.java:1: error: cannot find symbol");
     }
 
     @Test
@@ -292,7 +292,7 @@
                 "--module-path", modulePath.toString(),
                 "--limit-modules", "java.base",
                 "--module", "m2");
-        assertErrorPresent("error: module not found: m1");
+        assertMessagePresent("error: module not found: m1");
     }
 
     @Test
@@ -321,38 +321,6 @@
     }
 
     @Test
-    public void testPatchModuleOption(Path base) throws Exception {
-        Path src = base.resolve("src");
-        Path modulePath = base.resolve("modules");
-        Path patchPath = base.resolve("patch");
-
-        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
-        mb1.comment("Module on module path.")
-                .exports("pkg1")
-                .classes("package pkg1; /** Class A */ public class A { }")
-                .build(modulePath);
-
-        tb.writeJavaFiles(patchPath, "package pkg1; /** Class A */ public class A { public static int k; }");
-        new JavacTask(tb)
-                .files(patchPath.resolve("pkg1/A.java"))
-                .run();
-
-        ModuleBuilder mb2 = new ModuleBuilder(tb, "m2");
-        mb2.comment("The second module.")
-                .exports("pkg2")
-                .requires("m1")
-                .classes("package pkg2; /** Class B */ public class B { /** Field f */ public int f = pkg1.A.k; }")
-                .write(src);
-        execTask("--module-source-path", src.toString(),
-                "--patch-module", "m1=" + patchPath.toString(),
-                "--module-path", modulePath.toString(),
-                "--module", "m2");
-        checkModulesSpecified("m2");
-        checkPackagesIncluded("pkg2");
-        checkMembersSelected("pkg2.B.f");
-    }
-
-    @Test
     public void testAddReadsOption(Path base) throws Exception {
         Path src = base.resolve("src");
         Path modulePath = base.resolve("modules");
@@ -452,6 +420,7 @@
         checkPackagesIncluded("p");
         checkTypesIncluded("p.Main");
         checkPackagesNotIncluded(".*open.*");
+        assertMessageNotPresent("warning");
     }
 
     @Test
@@ -473,9 +442,46 @@
                 "--expand-requires", "transitive");
 
         checkModulesSpecified("M", "N", "O");
+        checkModulesNotSpecified("java.base");
         checkModulesIncluded("M", "N", "O");
+        checkModulesNotIncluded("java.base");
         checkPackagesIncluded("p", "openN", "openO");
         checkTypesIncluded("p.Main", "openN.N", "openO.O");
+        assertMessageNotPresent("warning");
+    }
+
+    @Test
+    public void testExpandRequiresTransitiveWithMandated(Path base) throws Exception {
+        Path src = base.resolve("src");
+
+        createAuxiliaryModules(src);
+
+        Path patchSrc = Paths.get(src.toString(), "patch");
+
+        new ModuleBuilder(tb, "M")
+                .comment("The M module.")
+                .requiresTransitive("N", src)
+                .requires("L", src)
+                .exports("p")
+                .classes("package p; public class Main { openO.O o; openN.N n; openL.L l; }")
+                .write(src);
+
+        // build the patching module
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n" +
+                "/** Class A */ public class A extends java.util.ArrayList { }");
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n"
+                + "/** Class B */ public class B { }");
+
+        execTask("--module-source-path", src.toString(),
+                "--patch-module", "java.base=" + patchSrc.toString(),
+                "--module", "M",
+                "--expand-requires", "transitive");
+
+        checkModulesSpecified("java.base", "M", "N", "O");
+        checkModulesIncluded("java.base", "M", "N", "O");
+        checkPackagesIncluded("p", "openN", "openO");
+        checkTypesIncluded("p.Main", "openN.N", "openO.O");
+        assertMessageNotPresent("warning");
     }
 
     @Test
@@ -497,13 +503,14 @@
                 "--module", "M",
                 "--expand-requires", "all");
 
-        checkModulesSpecified("M", "java.base", "N", "L", "O");
-        checkModulesIncluded("M", "java.base", "N", "L", "O");
+        checkModulesSpecified("M", "N", "L", "O");
+        checkModulesIncluded("M", "N", "L", "O");
         checkModulesNotIncluded("P", "J", "Q");
         checkPackagesIncluded("p", "openN", "openL", "openO");
         checkPackagesNotIncluded(".*openP.*", ".*openJ.*");
         checkTypesIncluded("p.Main", "openN.N", "openL.L", "openO.O");
         checkTypesNotIncluded(".*openP.*", ".*openJ.*");
+        assertMessageNotPresent("warning");
     }
 
     @Test
@@ -525,7 +532,7 @@
                 "--module", "MIA",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found.");
+        assertMessagePresent("javadoc: error - module MIA not found.");
     }
 
     @Test
@@ -547,7 +554,53 @@
                 "--module", "M,N,L,MIA,O,P",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found");
+        assertMessagePresent("javadoc: error - module MIA not found");
+    }
+
+    @Test
+    public void testSingleModuleOptionWithSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path mod = createSimpleModule(src, "m1");
+        execTask("--source-path", mod.toString(),
+                 "--module", "m1");
+        checkModulesSpecified("m1");
+        checkPackagesIncluded("p");
+        checkTypesIncluded("p.C");
+    }
+
+    @Test
+    public void testSingleModuleOptionWithMissingModuleInSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path mod = createSimpleModule(src, "m1");
+        execNegativeTask("--source-path", mod.toString(),
+                 "--module", "m2");
+        assertMessagePresent("source path does not contain module m2");
+    }
+
+    @Test
+    public void testMultipleModuleOptionWithSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path mod = createSimpleModule(src, "m1");
+        execNegativeTask("--source-path", mod.toString(),
+                 "--module", "m1,m2,m3");
+        assertMessagePresent("cannot use source path for multiple modules m1, m2, m3");
+    }
+
+    @Test
+    public void testSingleModuleOptionWithNoModuleOnSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path mod1 = Paths.get(src.toString(), "m1");
+        execNegativeTask("--source-path", mod1.toString(),
+                 "--module", "m1");
+        assertMessagePresent("module m1 not found on source path");
+    }
+
+    Path createSimpleModule(Path src, String mname) throws IOException {
+        Path mpath = Paths.get(src.toString(), mname);
+        tb.writeJavaFiles(mpath,
+                "module " + mname + " { exports p; }",
+                "package p; public class C { }");
+        return mpath;
     }
 
     void createAuxiliaryModules(Path src) throws IOException {
@@ -562,7 +615,7 @@
         new ModuleBuilder(tb, "L")
                 .comment("The L module.")
                 .exports("openL")
-                . requiresTransitive("P")
+                .requiresTransitive("P")
                 .classes("package openL; /** Class L open */ public class L { }")
                 .classes("package closedL;  /** Class L closed */ public class L { }")
                 .write(src);
@@ -584,7 +637,7 @@
                 .write(src);
 
         new ModuleBuilder(tb, "P")
-                .comment("The O module.")
+                .comment("The P module.")
                 .exports("openP")
                 .requires("J")
                 .classes("package openP; /** Class O open. */ public class O { openJ.J j; }")
--- a/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -180,7 +180,7 @@
                          "--module", "m1",
                          "-subpackages", "m1pub.pub1:pro");
 
-        assertErrorPresent("javadoc: error - No source files for package pro");
+        assertMessagePresent("javadoc: error - No source files for package pro");
     }
 
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/PatchModules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 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 8175346
+ * @summary Test patch module options
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main PatchModules
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.*;
+
+public class PatchModules extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new PatchModules().runTests();
+    }
+
+    // Case A.1, m2 augmenting m1
+    @Test
+    public void testPatchModuleOption(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path modulePath = base.resolve("modules");
+        Path patchPath = base.resolve("patch");
+
+        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
+        mb1.comment("Module on module path.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .build(modulePath);
+
+        tb.writeJavaFiles(patchPath, "package pkg1; /** Class A */ public class A { public static int k; }");
+        new JavacTask(tb)
+                .files(patchPath.resolve("pkg1/A.java"))
+                .run();
+
+        ModuleBuilder mb2 = new ModuleBuilder(tb, "m2");
+        mb2.comment("The second module.")
+                .exports("pkg2")
+                .requires("m1")
+                .classes("package pkg2; /** Class B */ public class B { /** Field f */ public int f = pkg1.A.k; }")
+                .write(src);
+        execTask("--module-source-path", src.toString(),
+                "--patch-module", "m1=" + patchPath.toString(),
+                "--module-path", modulePath.toString(),
+                "--module", "m2");
+        checkModulesSpecified("m2");
+        checkPackagesIncluded("pkg2");
+        checkMembersSelected("pkg2.B.f");
+    }
+
+    // Case A.2: use package, source form of m1 augmenting binary form of m1
+    @Test
+    public void testPatchModuleWithPackage(Path base)  throws Exception {
+        Path modulePath = base.resolve("modules");
+        Path moduleSrcPath = base.resolve("modulesSrc");
+
+        Path mpath = Paths.get(moduleSrcPath.toString(),  "m1");
+
+        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
+        mb1.comment("Module m1.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .classes("package pkg1.pkg2; /** Class B */ public class B { }")
+                .build(modulePath);
+
+        execTask("-hasDocComments",
+                "--module-path", modulePath.toString(),
+                "--add-modules", "m1",
+                "--patch-module", "m1=" + mpath.toString(),
+                "pkg1");
+        checkTypesIncluded("pkg1.A hasDocComments");
+    }
+
+     // Case A.2: use subpackages, source form of m1 augmenting binary form of m1
+    @Test
+    public void testPatchModuleWithSubPackages(Path base) throws Exception {
+        Path modulePath = base.resolve("modules");
+        Path moduleSrcPath = base.resolve("modulesSrc");
+
+        Path mpath = Paths.get(moduleSrcPath.toString(),  "m1");
+
+        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
+        mb1.comment("Module m1.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .classes("package pkg1.pkg2; /** Class B */ public class B { }")
+                .build(modulePath);
+
+        execTask("-hasDocComments",
+                "--module-path", modulePath.toString(),
+                "--add-modules", "m1",
+                "--patch-module", "m1=" + mpath.toString(),
+                "-subpackages", "pkg1");
+        checkTypesIncluded("pkg1.A hasDocComments");
+        checkTypesIncluded("pkg1.pkg2.B hasDocComments");
+    }
+
+    // Case B.1: (jsr166) augment and override system module
+    @Test
+    public void testPatchModuleModifyingSystemModule(Path base) throws Exception {
+        Path patchSrc = base.resolve("patch");
+
+        // build the patching sources
+        tb.writeJavaFiles(patchSrc, "package java.util;\n" +
+                "/** Class Collection */\n" +
+                "public interface Collection<K> {}");
+
+        tb.writeJavaFiles(patchSrc, "package java.util;\n"
+                + "/** Class MyCollection */\n" +
+                "public interface MyCollection<K> extends Collection {}");
+
+        execTask("-hasDocComments", "--patch-module", "java.base=" + patchSrc.toString(),
+                "java.util");
+
+        checkPackagesSpecified("java.util");
+        checkTypesIncluded("java.util.Collection hasDocComments",
+                "java.util.MyCollection hasDocComments");
+    }
+
+    // Case C.1: patch a user module's sources using source path
+    @Test
+    public void testPatchModuleUsingSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path patchSrc = base.resolve("patch");
+
+        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
+        mb1.comment("Module m1.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .write(src);
+
+        // build the patching module
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n" +
+                "/** Class A */ public class A extends java.util.ArrayList { }");
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n"
+                + "/** Class B */ public class B { }");
+
+        Path m1src = Paths.get(src.toString(), "m1");
+
+        execTask("--source-path", m1src.toString(),
+                "--patch-module", "m1=" + patchSrc.toString(),
+                "pkg1");
+
+        checkPackagesSpecified("pkg1");
+        checkModulesIncluded("m1");
+        checkTypesIncluded("pkg1.A", "pkg1.B");
+    }
+
+    // Case C.2: patch a user module's sources using module source path
+    @Test
+    public void testPatchModuleWithModuleSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path patchSrc = base.resolve("patch");
+
+        ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
+        mb1.comment("Module on module-source-path.")
+                .exports("pkg1")
+                .classes("package pkg1; /** Class A */ public class A { }")
+                .write(src);
+
+        // build the patching module
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n" +
+                "/** Class A */ public class A extends java.util.ArrayList { }");
+        tb.writeJavaFiles(patchSrc, "package pkg1;\n"
+                + "/** Class B */ public class B { }");
+
+
+        execTask("--module-source-path", src.toString(),
+                "--add-modules", "m1",
+                "--patch-module", "m1=" + patchSrc.toString(),
+                "pkg1");
+
+        checkPackagesSpecified("pkg1");
+        checkModulesIncluded("m1");
+        checkTypesIncluded("pkg1.A", "pkg1.B");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/ReleaseOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 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 8175346 8175277
+ * @summary Test release option interactions
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main ReleaseOptions
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.*;
+
+public class ReleaseOptions extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new ReleaseOptions().runTests();
+    }
+
+    @Test
+    public void testReleaseWithPatchModule(Path base) throws Exception {
+        Path src = Paths.get(base.toString(), "src");
+        Path mpath = Paths.get(src. toString(), "m");
+
+        tb.writeJavaFiles(mpath,
+                "module m { exports p; }",
+                "package p; public class C { }");
+
+        Task.Result result = execNegativeTask("--release", "8",
+                "--patch-module", "m=" + mpath.toString(),
+                "p");
+        assertMessagePresent(".*not allowed with target 1.8.*");
+        assertMessageNotPresent(".*Exception*");
+        assertMessageNotPresent(".java.lang.AssertionError.*");
+    }
+
+    @Test
+    public void testReleaseWithSourcepath(Path base) throws Exception {
+        Path src = Paths.get(base.toString(), "src");
+        Path mpath = Paths.get(src. toString(), "m");
+
+        tb.writeJavaFiles(mpath,
+                "module m { exports p; }",
+                "package p; public class C { }");
+
+        Task.Result result = execNegativeTask("--release", "8",
+                "--source-path", mpath.toString(),
+                "--module", "m");
+        assertMessagePresent(".*(use -source 9 or higher to enable modules).*");
+        assertMessageNotPresent(".*Exception*");
+        assertMessageNotPresent(".java.lang.AssertionError.*");
+    }
+
+    @Test
+    public void testReleaseWithModuleSourcepath(Path base) throws Exception {
+        Path src = Paths.get(base.toString(), "src");
+        Path mpath = Paths.get(src.toString(), "m");
+
+        tb.writeJavaFiles(mpath,
+                "module m { exports p; }",
+                "package p; public class C { }");
+
+        Task.Result result = execNegativeTask("--release", "8",
+                "--module-source-path", src.toString(),
+                "--module", "m");
+        assertMessagePresent(".*not allowed with target 1.8.*");
+        assertMessageNotPresent(".*Exception*");
+        assertMessageNotPresent(".java.lang.AssertionError.*");
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -24,7 +24,6 @@
 package p;
 
 import java.io.*;
-import jdk.javadoc.internal.tool.Main;
 
 public class OutputRedirect {
     private static final PrintStream originalOutput = System.err;
@@ -47,9 +46,9 @@
         PrintWriter sink = new PrintWriter(new ByteArrayOutputStream());
 
         // execute javadoc
-        int result = Main.execute(new String[] {"p"}, sink);
+        int result = jdk.javadoc.internal.tool.Main.execute(new String[] {"p"}, sink);
 
-        // test whether javadoc did any output to System.out
+        // tests whether javadoc wrote to System.out
         if (redirectedOutput.toByteArray().length > 0) {
             originalOutput.println("Test failed; here's what javadoc wrote on its standard output:");
             originalOutput.println(redirectedOutput.toString());
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144095 8164825 8169818 8153402 8165405
+ * @bug 8144095 8164825 8169818 8153402 8165405 8177079
  * @summary Test Command Completion
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -173,7 +173,9 @@
                 "/save ", "/set "),
                 a -> assertCompletion(a, "/help /set |", false,
                 "editor", "feedback", "format", "mode", "prompt", "start", "truncation"),
-                a -> assertCompletion(a, "/help /edit |", false)
+                a -> assertCompletion(a, "/help /edit |", false),
+                a -> assertCompletion(a, "/help dr|", false,
+                "drop ")
         );
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/MergedTabShiftTabTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 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 8177076
+ * @modules
+ *     jdk.compiler/com.sun.tools.javac.api
+ *     jdk.compiler/com.sun.tools.javac.main
+ *     jdk.jshell/jdk.internal.jshell.tool.resources:open
+ *     jdk.jshell/jdk.jshell:open
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
+ * @build Compiler
+ * @build MergedTabShiftTabTest
+ * @run testng MergedTabShiftTabTest
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jdk.jshell.JShell;
+import jdk.jshell.tool.JavaShellToolBuilder;
+import org.testng.annotations.Test;
+
+@Test
+public class MergedTabShiftTabTest {
+
+    public void testCommand() throws Exception {
+        doRunTest((inputSink, out) -> {
+            inputSink.write("1\n");
+            waitOutput(out, "\u0005");
+            inputSink.write("/\011");
+            waitOutput(out, ".*/edit.*/list.*\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
+            inputSink.write("\011");
+            waitOutput(out,   ".*\n/edit\n" + Pattern.quote(getResource("help.edit.summary")) +
+                            "\n.*\n/list\n" + Pattern.quote(getResource("help.list.summary")) +
+                            ".*\n\n" + Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/");
+            inputSink.write("\011");
+            waitOutput(out,  "/!\n" +
+                            Pattern.quote(getResource("help.bang")) + "\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
+                            "\r\u0005/");
+            inputSink.write("\011");
+            waitOutput(out,  "/-<n>\n" +
+                            Pattern.quote(getResource("help.previous")) + "\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
+                            "\r\u0005/");
+
+            inputSink.write("lis\011");
+            waitOutput(out, "list $");
+
+            inputSink.write("\011");
+            waitOutput(out, ".*-all.*" +
+                            "\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list ");
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", "    ")));
+
+            inputSink.write("\u0003/env \011");
+            waitOutput(out, "\u0005/env -\n" +
+                            "-add-exports    -add-modules    -class-path     -module-path    \n" +
+                            "\r\u0005/env -");
+
+            inputSink.write("\011");
+            waitOutput(out, "-add-exports    -add-modules    -class-path     -module-path    \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
+                            "\r\u0005/env -");
+
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.env.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n" +
+                            "\r\u0005/env -");
+
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.env").replaceAll("\t", "    ")) + "\n" +
+                            "\r\u0005/env -");
+
+            inputSink.write("\011");
+            waitOutput(out, "-add-exports    -add-modules    -class-path     -module-path    \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
+                            "\r\u0005/env -");
+
+            inputSink.write("\u0003/exit \011");
+            waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.exit")) + "\n" +
+                            "\r\u0005/exit ");
+            inputSink.write("\011");
+            waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
+            inputSink.write("\u0003/doesnotexist\011");
+            waitOutput(out, "\u0005/doesnotexist\n" +
+                            Pattern.quote(getResource("jshell.console.no.such.command")) + "\n" +
+                            "\n" +
+                            "\r\u0005/doesnotexist");
+        });
+    }
+
+    public void testExpression() throws Exception {
+        Path classes = prepareZip();
+        doRunTest((inputSink, out) -> {
+            inputSink.write("/env -class-path " + classes.toString() + "\n");
+            waitOutput(out, Pattern.quote(getResource("jshell.msg.set.restore")) + "\n\u0005");
+            inputSink.write("import jshelltest.*;\n");
+            waitOutput(out, "\n\u0005");
+
+            //-> <tab>
+            inputSink.write("\011");
+            waitOutput(out, getMessage("jshell.console.completion.all.completions.number", "[0-9]+"));
+            inputSink.write("\011");
+            waitOutput(out, ".*String.*StringBuilder.*\n\r\u0005");
+
+            //new JShellTes<tab>
+            inputSink.write("new JShellTes\011");
+            waitOutput(out, "t\nJShellTest\\(      JShellTestAux\\(   \n\r\u0005new JShellTest");
+
+            //new JShellTest<tab>
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(      JShellTestAux\\(   \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.completion.current.signatures")) + "\n" +
+                            "jshelltest.JShellTest\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.documentation")) + "\n" +
+                            "\r\u0005new JShellTest");
+            inputSink.write("\011");
+            waitOutput(out, "jshelltest.JShellTest\n" +
+                            "JShellTest 0\n" +
+                            "\r\u0005new JShellTest");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(      JShellTestAux\\(   \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.completion.current.signatures")) + "\n" +
+                            "jshelltest.JShellTest\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.documentation")) + "\n" +
+                            "\r\u0005new JShellTest");
+
+            //new JShellTest(<tab>
+            inputSink.write("(\011");
+            waitOutput(out, "\\(\n" +
+                            Pattern.quote(getResource("jshell.console.completion.current.signatures")) + "\n" +
+                            "JShellTest\\(String str\\)\n" +
+                            "JShellTest\\(String str, int i\\)\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.documentation")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(String str\\)\n" +
+                            "JShellTest 1\n" +
+                            "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.page")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.javadoc")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(String str, int i\\)\n" +
+                            "JShellTest 2\n" +
+                            "\n" +
+                            getMessage("jshell.console.completion.all.completions.number", "[0-9]+") + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, ".*String.*StringBuilder.*\n\r\u0005new JShellTest\\(");
+
+            inputSink.write("\u0003String str = \"\";\nnew JShellTest(");
+            waitOutput(out, "\u0005new JShellTest\\(");
+
+            inputSink.write("\011");
+            waitOutput(out, "\n" +
+                            "str   \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.completion.current.signatures")) + "\n" +
+                            "JShellTest\\(String str\\)\n" +
+                            "JShellTest\\(String str, int i\\)\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.documentation")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(String str\\)\n" +
+                            "JShellTest 1\n" +
+                            "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.page")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.next.javadoc")) + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(String str, int i\\)\n" +
+                            "JShellTest 2\n" +
+                            "\n" +
+                            getMessage("jshell.console.completion.all.completions.number", "[0-9]+") + "\n" +
+                            "\r\u0005new JShellTest\\(");
+            inputSink.write("\011");
+            waitOutput(out, ".*String.*StringBuilder.*\n\r\u0005new JShellTest\\(");
+
+            inputSink.write("\u0003JShellTest t = new JShellTest\011");
+            waitOutput(out, "\u0005JShellTest t = new JShellTest\n" +
+                            "JShellTest\\(   \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.completion.current.signatures")) + "\n" +
+                            "jshelltest.JShellTest\n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.completion.all.completions")) + "\n" +
+                            "\r\u0005JShellTest t = new JShellTest");
+            inputSink.write("\011");
+            waitOutput(out, "JShellTest\\(      JShellTestAux\\(   \n" +
+                            "\n" +
+                            Pattern.quote(getResource("jshell.console.see.documentation")) + "\n" +
+                            "\r\u0005JShellTest t = new JShellTest");
+
+            inputSink.write("\u0003JShellTest t = new \011");
+            waitOutput(out, "\u0005JShellTest t = new \n" +
+                            "JShellTest\\(   \n" +
+                            "\n" +
+                            getMessage("jshell.console.completion.all.completions.number", "[0-9]+") + "\n" +
+                            "\r\u0005JShellTest t = new ");
+            inputSink.write("\011");
+            waitOutput(out, ".*String.*StringBuilder.*\n\r\u0005JShellTest t = new ");
+
+            inputSink.write("\u0003class JShelX{}\n");
+            inputSink.write("new JShel\011");
+            waitOutput(out, "\u0005new JShel\n" +
+                            "JShelX\\(\\)         JShellTest\\(      JShellTestAux\\(   \n" +
+                            "\r\u0005new JShel");
+
+            //no crash:
+            inputSink.write("\u0003new Stringbuil\011");
+            waitOutput(out, "\u0005new Stringbuil\u0007");
+        });
+    }
+
+    private void doRunTest(Test test) throws Exception {
+        PipeInputStream input = new PipeInputStream();
+        StringBuilder out = new StringBuilder();
+        PrintStream outS = new PrintStream(new OutputStream() {
+            @Override public void write(int b) throws IOException {
+                synchronized (out) {
+                    System.out.print((char) b);
+                    out.append((char) b);
+                    out.notifyAll();
+                }
+            }
+        });
+        Thread runner = new Thread(() -> {
+            try {
+                JavaShellToolBuilder.builder()
+                        .in(input, input)
+                        .out(outS)
+                        .err(outS)
+                        .promptCapture(true)
+                        .persistence(new HashMap<>())
+                        .locale(Locale.US)
+                        .run("--no-startup");
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        });
+
+        Writer inputSink = new OutputStreamWriter(input.createOutput()) {
+            @Override
+            public void write(String str) throws IOException {
+                super.write(str);
+                flush();
+            }
+        };
+
+        runner.start();
+
+        try {
+            waitOutput(out, "\u0005");
+            test.test(inputSink, out);
+        } finally {
+            inputSink.write("\003\003/exit");
+
+            runner.join(1000);
+            if (runner.isAlive()) {
+                runner.stop();
+            }
+        }
+    }
+
+    interface Test {
+        public void test(Writer inputSink, StringBuilder out) throws Exception;
+    }
+
+    private Path prepareZip() {
+        String clazz1 =
+                "package jshelltest;\n" +
+                "/**JShellTest 0" +
+                " */\n" +
+                "public class JShellTest {\n" +
+                "    /**JShellTest 1\n" +
+                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
+                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
+                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
+                "     */\n" +
+                "    public JShellTest(String str) {}\n" +
+                "    /**JShellTest 2" +
+                "     */\n" +
+                "    public JShellTest(String str, int i) {}\n" +
+                "}\n";
+
+        String clazz2 =
+                "package jshelltest;\n" +
+                "/**JShellTestAux 0" +
+                " */\n" +
+                "public class JShellTestAux {\n" +
+                "    /**JShellTest 1" +
+                "     */\n" +
+                "    public JShellTestAux(String str) { }\n" +
+                "    /**JShellTest 2" +
+                "     */\n" +
+                "    public JShellTestAux(String str, int i) { }\n" +
+                "}\n";
+
+        Path srcZip = Paths.get("src.zip");
+
+        try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
+            out.putNextEntry(new JarEntry("jshelltest/JShellTest.java"));
+            out.write(clazz1.getBytes());
+            out.putNextEntry(new JarEntry("jshelltest/JShellTestAux.java"));
+            out.write(clazz2.getBytes());
+        } catch (IOException ex) {
+            throw new IllegalStateException(ex);
+        }
+
+        compiler.compile(clazz1, clazz2);
+
+        try {
+            Field availableSources = Class.forName("jdk.jshell.SourceCodeAnalysisImpl").getDeclaredField("availableSourcesOverride");
+            availableSources.setAccessible(true);
+            availableSources.set(null, Arrays.asList(srcZip));
+        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException ex) {
+            throw new IllegalStateException(ex);
+        }
+
+        return compiler.getClassDir();
+    }
+    //where:
+        private final Compiler compiler = new Compiler();
+
+    private final ResourceBundle resources;
+    {
+        resources = ResourceBundle.getBundle("jdk.internal.jshell.tool.resources.l10n", Locale.US, JShell.class.getModule());
+    }
+
+    private String getResource(String key) {
+        return resources.getString(key);
+    }
+
+    private String getMessage(String key, Object... args) {
+        return MessageFormat.format(resources.getString(key), args);
+    }
+
+    private static final long TIMEOUT;
+
+    static {
+        long factor;
+
+        try {
+            factor = (long) Double.parseDouble(System.getProperty("test.timeout.factor", "1"));
+        } catch (NumberFormatException ex) {
+            factor = 1;
+        }
+        TIMEOUT = 60_000 * factor;
+    }
+
+    private void waitOutput(StringBuilder out, String expected) {
+        expected = expected.replaceAll("\n", System.getProperty("line.separator"));
+        Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL);
+        synchronized (out) {
+            long s = System.currentTimeMillis();
+
+            while (true) {
+                Matcher m = expectedPattern.matcher(out);
+                if (m.find()) {
+                    out.delete(0, m.end() + 1);
+                    return ;
+                }
+                long e =  System.currentTimeMillis();
+                if ((e - s) > TIMEOUT) {
+                    throw new IllegalStateException("Timeout waiting for: " + quote(expected) + ", actual output so far: " + quote(out.toString()));
+                }
+                try {
+                    out.wait(TIMEOUT);
+                } catch (InterruptedException ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    private String quote(String original) {
+        StringBuilder output = new StringBuilder();
+
+        for (char c : original.toCharArray()) {
+            if (c < 32) {
+                output.append(String.format("\\u%04X", (int) c));
+            } else {
+                output.append(c);
+            }
+        }
+
+        return output.toString();
+    }
+
+    private static class PipeInputStream extends InputStream {
+
+        private static final int INITIAL_SIZE = 128;
+        private int[] buffer = new int[INITIAL_SIZE];
+        private int start;
+        private int end;
+        private boolean closed;
+
+        @Override
+        public synchronized int read() throws IOException {
+            if (start == end && !closed) {
+                inputNeeded();
+            }
+            while (start == end) {
+                if (closed) {
+                    return -1;
+                }
+                try {
+                    wait();
+                } catch (InterruptedException ex) {
+                    //ignore
+                }
+            }
+            try {
+                return buffer[start];
+            } finally {
+                start = (start + 1) % buffer.length;
+            }
+        }
+
+        @Override
+        public synchronized int read(byte[] b, int off, int len) throws IOException {
+            if (b == null) {
+                throw new NullPointerException();
+            } else if (off < 0 || len < 0 || len > b.length - off) {
+                throw new IndexOutOfBoundsException();
+            } else if (len == 0) {
+                return 0;
+            }
+
+            int c = read();
+            if (c == -1) {
+                return -1;
+            }
+            b[off] = (byte)c;
+
+            int totalRead = 1;
+            while (totalRead < len && start != end) {
+                int r = read();
+                if (r == (-1))
+                    break;
+                b[off + totalRead++] = (byte) r;
+            }
+            return totalRead;
+        }
+
+        protected void inputNeeded() throws IOException {}
+
+        private synchronized void write(int b) {
+            if (closed) {
+                throw new IllegalStateException("Already closed.");
+            }
+            int newEnd = (end + 1) % buffer.length;
+            if (newEnd == start) {
+                //overflow:
+                int[] newBuffer = new int[buffer.length * 2];
+                int rightPart = (end > start ? end : buffer.length) - start;
+                int leftPart = end > start ? 0 : start - 1;
+                System.arraycopy(buffer, start, newBuffer, 0, rightPart);
+                System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
+                buffer = newBuffer;
+                start = 0;
+                end = rightPart + leftPart;
+                newEnd = end + 1;
+            }
+            buffer[end] = b;
+            end = newEnd;
+            notifyAll();
+        }
+
+        @Override
+        public synchronized void close() {
+            closed = true;
+            notifyAll();
+        }
+
+        public OutputStream createOutput() {
+            return new OutputStream() {
+                @Override public void write(int b) throws IOException {
+                    PipeInputStream.this.write(b);
+                }
+                @Override
+                public void write(byte[] b, int off, int len) throws IOException {
+                    for (int i = 0 ; i < len ; i++) {
+                        write(Byte.toUnsignedInt(b[off + i]));
+                    }
+                }
+                @Override
+                public void close() throws IOException {
+                    PipeInputStream.this.close();
+                }
+            };
+        }
+
+    }
+
+}
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -350,7 +350,9 @@
                 (a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"),
                 (a) -> assertHelp(a, "/? /li", "/list -all", "snippets"),
                 (a) -> assertHelp(a, "/help /set prompt", "optionally contain '%s'", "quoted"),
-                (a) -> assertHelp(a, "/help /help", "/help <command>")
+                (a) -> assertHelp(a, "/help /help", "/help <command>"),
+                (a) -> assertHelp(a, "/help li", "/list -start"),
+                (a) -> assertHelp(a, "/help fe", "/set feedback -retain")
         );
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8176714/FieldOverloadKindNotAssignedTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 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 8176714
+ * @summary javac is wrongly assuming that field JCMemberReference.overloadKind has been assigned to
+ * @library /tools/javac/lib
+ * @modules jdk.compiler/com.sun.source.util
+ *          jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @build DPrinter
+ * @run main FieldOverloadKindNotAssignedTest
+ */
+
+import java.net.URI;
+import java.util.Arrays;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCMemberReference;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+
+public class FieldOverloadKindNotAssignedTest {
+    public static void main(String... args) throws Exception {
+        new FieldOverloadKindNotAssignedTest().run();
+    }
+
+    void run() throws Exception {
+        Context context = new Context();
+        JavacFileManager.preRegister(context);
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, Arrays.asList(new JavaSource()));
+        Iterable<? extends CompilationUnitTree> elements = ct.parse();
+        ct.analyze();
+        Assert.check(elements.iterator().hasNext());
+        JCTree topLevel = (JCTree)elements.iterator().next();
+        new TreeScanner() {
+            @Override
+            public void visitReference(JCMemberReference tree) {
+                Assert.check(tree.getOverloadKind() != null);
+            }
+        }.scan(topLevel);
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        String source =
+                "import java.util.function.*;\n" +
+
+                "class Test {\n" +
+                "    void m(Predicate<String> psi) {}\n" +
+                "    void m(Function<String, String> fss) {}\n" +
+
+                "    void foo(boolean b) {\n" +
+                "        m(b ? s -> false : Test::g);\n" +
+                "    }\n" +
+
+                "    static boolean g(String s) { return false; }\n" +
+                "    static boolean g(Integer i) { return false; }\n" +
+                "}";
+
+        public JavaSource() {
+            super(URI.create("myfo:/Foo.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8176714/TimingOfMReferenceCheckingTest01.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 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 8176714
+ * @summary javac is wrongly assuming that field JCMemberReference.overloadKind has been assigned to
+ * @compile TimingOfMReferenceCheckingTest01.java
+ */
+
+import java.util.function.*;
+
+public class TimingOfMReferenceCheckingTest01 {
+    <Z> void g(Consumer<Z> fzr, Z z) {}
+
+    void test(boolean cond) {
+       g(cond ? this::m : this::m, "");
+    }
+
+    void m(String s) {}
+    void m(Integer i) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8176714/TimingOfMReferenceCheckingTest02.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 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 8176714
+ * @summary javac is wrongly assuming that field JCMemberReference.overloadKind has been assigned to
+ * @compile TimingOfMReferenceCheckingTest02.java
+ */
+
+import java.util.function.*;
+
+public class TimingOfMReferenceCheckingTest02 {
+    <Z> void g(Consumer<Z> fzr, Z z) {}
+   <T> T f(T t) { return null; }
+
+   void test(boolean cond) {
+        g(cond ?
+            f(cond ?
+                this::m :
+                this::m) :
+            this::m, "");
+    }
+
+    void m(String s) {}
+    void m(Integer i) {}
+}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/ModuleInfoWithPatchedModuleClassoutput.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.module-info.with.patched.module.classoutput
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/additional/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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
- * 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 mod {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/patchmodule/java.compiler/javax/lang/model/element/Extra.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.lang.model.element;
-
-public interface Extra {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/ModuleInfoWithPatchedModule.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.module-info.with.patched.module.sourcepath
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/javax/lang/model/element/Extra.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.lang.model.element;
-
-public interface Extra {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/module-info.java	Wed Jul 05 23:09:24 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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
- * 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 java.compiler {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8176534/T8176534.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8176534
+ * @summary Missing check against target-type during applicability inference
+ * @compile/fail/ref=T8176534.out -Werror -Xlint:unchecked -XDrawDiagnostics T8176534.java
+ */
+
+import java.util.*;
+
+abstract class T8176534 {
+    List<String> f(Enumeration e) {
+        return newArrayList(forEnumeration(e));
+    }
+
+    abstract <T> Iterator<T> forEnumeration(Enumeration<T> e);
+    abstract <E> ArrayList<E> newArrayList(Iterator<? extends E> xs);
+    abstract <E> ArrayList<E> newArrayList(Iterable<? extends E> xs);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8176534/T8176534.out	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,8 @@
+T8176534.java:12:43: compiler.warn.unchecked.meth.invocation.applied: kindname.method, forEnumeration, java.util.Enumeration<T>, java.util.Enumeration, kindname.class, T8176534
+T8176534.java:12:44: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Enumeration, java.util.Enumeration<T>
+T8176534.java:12:28: compiler.warn.unchecked.meth.invocation.applied: kindname.method, newArrayList, java.util.Iterator<? extends E>, java.util.Iterator, kindname.class, T8176534
+T8176534.java:12:43: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Iterator, java.util.Iterator<? extends E>
+T8176534.java:12:28: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.ArrayList, java.util.List<java.lang.String>
+- compiler.err.warnings.and.werror
+1 error
+5 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8176534/TestUncheckedCalls.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import combo.ComboInstance;
+import combo.ComboParameter;
+import combo.ComboTask.Result;
+import combo.ComboTestHelper;
+
+import javax.lang.model.element.Element;
+import java.util.stream.Stream;
+
+/*
+ * @test
+ * @bug 8176534
+ * @summary Missing check against target-type during applicability inference
+ * @library /tools/javac/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @build combo.ComboTestHelper
+ *
+ * @run main TestUncheckedCalls
+ */
+public class TestUncheckedCalls extends ComboInstance<TestUncheckedCalls> {
+    enum InputExpressionKind implements ComboParameter {
+        A("(A)null"),
+        A_STRING("(A<String>)null"),
+        B("(B)null"),
+        B_STRING("(B<String>)null");
+
+        String inputExpr;
+
+        InputExpressionKind(String inputExpr) {
+            this.inputExpr = inputExpr;
+        }
+
+
+        @Override
+        public String expand(String optParameter) {
+            return inputExpr;
+        }
+    }
+
+    enum TypeKind implements ComboParameter {
+        Z("Z"),
+        C_T("#C<T>"),
+        C_STRING("#C<String>"),
+        C("#C");
+
+        String typeTemplate;
+
+        TypeKind(String typeTemplate) {
+            this.typeTemplate = typeTemplate;
+        }
+
+        boolean hasTypeVars() {
+            return this == Z || this == C_T;
+        }
+
+        @Override
+        public String expand(String className) {
+            return typeTemplate.replaceAll("#C", className);
+        }
+    }
+
+    enum TypeVarsKind implements ComboParameter {
+        NONE("", "Object"),
+        Z_T("<Z extends #C<T>, T>", "Z");
+
+        String typeVarsTemplate;
+        String paramString;
+
+        TypeVarsKind(String typeVarsTemplate, String paramString) {
+            this.typeVarsTemplate = typeVarsTemplate;
+            this.paramString = paramString;
+        }
+
+
+        @Override
+        public String expand(String className) {
+            if (className.equals("Z")) {
+                return paramString;
+            } else {
+                return typeVarsTemplate.replaceAll("#C", className);
+            }
+        }
+    }
+
+    enum CallKind implements ComboParameter {
+        M("M(#{IN}, #{IN})"),
+        M_G("M(G(#{IN}, #{IN}), #{IN})"),
+        M_G_G("M(G(#{IN}, #{IN}), G(#{IN}, #{IN}))");
+
+        String callExpr;
+
+        CallKind(String callExpr) {
+            this.callExpr = callExpr;
+        }
+
+
+        @Override
+        public String expand(String optParameter) {
+            return callExpr;
+        }
+    }
+
+    enum DeclKind implements ComboParameter {
+        NONE(""),
+        ONE("#{TVARS[#M_IDX].I1} #{RET[#M_IDX].A} #M(#{ARG[#M_IDX].A} x1, #{TVARS[#M_IDX].Z} x2) { return null; }"),
+        TWO("#{TVARS[#M_IDX].I1} #{RET[#M_IDX].A} #M(#{ARG[#M_IDX].A} x1, #{TVARS[#M_IDX].Z} x2) { return null; }\n" +
+        "    #{TVARS[#M_IDX].I2} #{RET[#M_IDX].B} #M(#{ARG[#M_IDX].B} x1, #{TVARS[#M_IDX].Z} x2) { return null; }");
+
+        String declTemplate;
+
+        DeclKind(String declTemplate) {
+            this.declTemplate = declTemplate;
+        }
+
+        @Override
+        public String expand(String methName) {
+            return declTemplate.replaceAll("#M_IDX", methName.equals("M") ? "0" : "1")
+                    .replaceAll("#M", methName);
+
+        }
+    }
+
+    static final String sourceTemplate =
+            "class Test {\n" +
+            "   interface I1<X> { }\n" +
+            "   interface I2<X> { }\n" +
+            "   static class A<X> implements I1<X> { }\n" +
+            "   static class B<X> implements I2<X> { }\n" +
+            "   #{DECL[0].M}\n" +
+            "   #{DECL[1].G}\n" +
+            "   void test() {\n" +
+            "       #{CALL};\n" +
+            "   }\n" +
+            "}\n";
+
+    public static void main(String... args) throws Exception {
+        new ComboTestHelper<TestUncheckedCalls>()
+                .withFilter(TestUncheckedCalls::arityFilter)
+                .withFilter(TestUncheckedCalls::declFilter)
+                .withFilter(TestUncheckedCalls::tvarFilter)
+                .withFilter(TestUncheckedCalls::inputExprFilter)
+                .withDimension("IN", (x, expr) -> x.inputExpressionKind = expr, InputExpressionKind.values())
+                .withDimension("CALL", (x, expr) -> x.callKind = expr, CallKind.values())
+                .withArrayDimension("DECL", (x, decl, idx) -> x.decls[idx] = x.new Decl(decl, idx), 2, DeclKind.values())
+                .withArrayDimension("TVARS", (x, tvars, idx) -> x.typeVarsKinds[idx] = tvars, 2, TypeVarsKind.values())
+                .withArrayDimension("RET", (x, ret, idx) -> x.returnKinds[idx] = ret, 2, TypeKind.values())
+                .withArrayDimension("ARG", (x, arg, idx) -> x.argumentKinds[idx] = arg, 2, TypeKind.values())
+                .run(TestUncheckedCalls::new);
+    }
+
+    class Decl {
+        private DeclKind declKind;
+        private int index;
+
+        Decl(DeclKind declKind, int index) {
+            this.declKind = declKind;
+            this.index = index;
+        }
+
+        boolean hasKind(DeclKind declKind) {
+            return this.declKind == declKind;
+        }
+
+        boolean isGeneric() {
+            return typeVarsKind() == TypeVarsKind.Z_T;
+        }
+
+        TypeKind returnKind() {
+            return returnKinds[index];
+        }
+
+        TypeKind argumentsKind() {
+            return argumentKinds[index];
+        }
+
+        TypeVarsKind typeVarsKind() {
+            return typeVarsKinds[index];
+        }
+    }
+
+    CallKind callKind;
+    InputExpressionKind inputExpressionKind;
+    TypeKind[] returnKinds = new TypeKind[2];
+    TypeKind[] argumentKinds = new TypeKind[2];
+    TypeVarsKind[] typeVarsKinds = new TypeVarsKind[2];
+    Decl[] decls = new Decl[2];
+
+    boolean arityFilter() {
+        return (callKind == CallKind.M || !decls[1].hasKind(DeclKind.NONE)) &&
+                !decls[0].hasKind(DeclKind.NONE);
+    }
+
+    boolean declFilter() {
+        return Stream.of(decls)
+                .filter(d -> d.hasKind(DeclKind.NONE))
+                .flatMap(d -> Stream.of(d.returnKind(), d.argumentsKind(), d.typeVarsKind()))
+                .noneMatch(tk -> tk.ordinal() != 0);
+    }
+
+    boolean tvarFilter() {
+        return Stream.of(decls)
+                .filter(d -> !d.hasKind(DeclKind.NONE))
+                .filter(d -> !d.isGeneric())
+                .flatMap(d -> Stream.of(d.returnKind(), d.argumentsKind()))
+                .noneMatch(TypeKind::hasTypeVars);
+    }
+
+    boolean inputExprFilter() {
+        return (inputExpressionKind != InputExpressionKind.B && inputExpressionKind != InputExpressionKind.B_STRING) ||
+                Stream.of(decls).allMatch(d -> d.declKind == DeclKind.TWO);
+    }
+
+    @Override
+    public void doWork() throws Throwable {
+        check(newCompilationTask()
+                .withSourceFromTemplate(sourceTemplate)
+                .analyze());
+    }
+
+    void check(Result<Iterable<? extends Element>> result) {
+        if (result.hasErrors()) {
+            fail("compiler error:\n" +
+                    result.compilationInfo());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8177097/T8177097a.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8177097
+ * @summary Generic method reference returning wildcard parameterized type does not compile
+ * @compile T8177097a.java
+ */
+
+import java.util.Map;
+
+class T8177097a {
+    interface X<O> {
+        Map<?, O> apply();
+    }
+
+    <O> void go(X<O> x) { }
+
+    static <I> Map<?, Integer> a() {
+        return null;
+    }
+
+    void test() {
+        go(T8177097a::a);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8177097/T8177097b.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8177097
+ * @summary Generic method reference returning wildcard parameterized type does not compile
+ * @compile T8177097b.java
+ */
+
+import java.util.Map;
+
+class T8177097b {
+    interface X<O> {
+        O apply(Class<Map<Integer, ?>> m2);
+    }
+
+    <O> void go(X<O> x) {}
+
+    static <I> I a(Class<I> c) { return null; }
+
+
+    void test() {
+        go(T8177097b::a);
+    }
+}
--- a/langtools/test/tools/javac/modules/AnnotationProcessing.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8133884 8162711 8133896 8172158 8172262 8173636
+ * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119
  * @summary Verify that annotation processing works.
  * @library /tools/lib
  * @modules
@@ -37,10 +37,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.UncheckedIOException;
 import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -49,6 +51,7 @@
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -527,53 +530,173 @@
 
         tb.writeJavaFiles(m1,
                           "module m1x { exports api1; }",
-                          "package api1; public class Api { GenApi ga; impl.Impl i; }");
+                          "package api1; public class Api { }",
+                          "package clash; public class C { }");
 
         writeFile("1", m1, "api1", "api");
-        writeFile("1", m1, "impl", "impl");
+        writeFile("2", m1, "clash", "clash");
 
         Path m2 = moduleSrc.resolve("m2x");
 
         tb.writeJavaFiles(m2,
                           "module m2x { requires m1x; exports api2; }",
-                          "package api2; public class Api { api1.GenApi ga1; GenApi qa2; impl.Impl i;}");
+                          "package api2; public class Api { }",
+                          "package clash; public class C { }");
+
+        writeFile("3", m2, "api2", "api");
+        writeFile("4", m2, "clash", "api");
+
+        //passing testcases:
+        for (String module : Arrays.asList("", "m1x/")) {
+            for (String originating : Arrays.asList("", ", jlObject")) {
+                tb.writeJavaFiles(m1,
+                                  "package test; class Test { api1.Impl i; }");
 
-        writeFile("2", m2, "api2", "api");
-        writeFile("2", m2, "impl", "impl");
+                //source:
+                runCompiler(base,
+                            moduleSrc,
+                            classes,
+                            "createSource(() -> filer.createSourceFile(\"" + module + "api1.Impl\"" + originating + "), \"api1.Impl\", \"package api1; public class Impl {}\")",
+                            "--module-source-path", moduleSrc.toString());
+                assertFileExists(classes, "m1x", "api1", "Impl.class");
+
+                //class:
+                runCompiler(base,
+                            moduleSrc,
+                            classes,
+                            "createClass(() -> filer.createClassFile(\"" + module + "api1.Impl\"" + originating + "), \"api1.Impl\", \"package api1; public class Impl {}\")",
+                            "--module-source-path", moduleSrc.toString());
+                assertFileExists(classes, "m1x", "api1", "Impl.class");
+
+                Files.delete(m1.resolve("test").resolve("Test.java"));
 
-        for (FileType fileType : FileType.values()) {
-            if (Files.isDirectory(classes)) {
-                tb.cleanDirectory(classes);
-            } else {
-                Files.createDirectories(classes);
+                //resource class output:
+                runCompiler(base,
+                            moduleSrc,
+                            classes,
+                            "createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"" + module + "api1\", \"impl\"" + originating + "), \"impl\", \"impl\")",
+                            "--module-source-path", moduleSrc.toString());
+                assertFileExists(classes, "m1x", "api1", "impl");
             }
+        }
+
+        //get resource module source path:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "doReadResource(() -> filer.getResource(StandardLocation.MODULE_SOURCE_PATH, \"m1x/api1\", \"api\"), \"1\")",
+                    "--module-source-path", moduleSrc.toString());
+
+        //can generate resources to the single root module:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"m1x/impl\", \"impl\"), \"impl\", \"impl\")",
+                    "--module-source-path", moduleSrc.toString());
+        assertFileExists(classes, "m1x", "impl", "impl");
+
+        //check --default-module-for-created-files option:
+        for (String pack : Arrays.asList("clash", "doesnotexist")) {
+            tb.writeJavaFiles(m1,
+                              "package test; class Test { " + pack + ".Pass i; }");
+            runCompiler(base,
+                        moduleSrc,
+                        classes,
+                        "createSource(() -> filer.createSourceFile(\"" + pack + ".Pass\")," +
+                        "                                          \"" + pack + ".Pass\"," +
+                        "                                          \"package " + pack + ";" +
+                        "                                            public class Pass { }\")",
+                        "--module-source-path", moduleSrc.toString(),
+                        "--default-module-for-created-files=m1x");
+            assertFileExists(classes, "m1x", pack, "Pass.class");
+            assertFileNotExists(classes, "m2x", pack, "Pass.class");
 
-            new JavacTask(tb)
-              .options("-processor", MultiModeAPITestAP.class.getName(),
-                       "--module-source-path", moduleSrc.toString(),
-                       "-Afiletype=" + fileType.name())
-              .outdir(classes)
-              .files(findJavaFiles(moduleSrc))
-              .run()
-              .writeAll();
+            runCompiler(base,
+                        moduleSrc,
+                        classes,
+                        "createClass(() -> filer.createClassFile(\"" + pack + ".Pass\")," +
+                        "                                        \"" + pack + ".Pass\"," +
+                        "                                        \"package " + pack + ";" +
+                        "                                          public class Pass { }\")",
+                        "--module-source-path", moduleSrc.toString(),
+                        "--default-module-for-created-files=m1x");
+            assertFileExists(classes, "m1x", pack, "Pass.class");
+            assertFileNotExists(classes, "m2x", pack, "Pass.class");
+
+            Files.delete(m1.resolve("test").resolve("Test.java"));
+
+            runCompiler(base,
+                        moduleSrc,
+                        classes,
+                        "createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT," +
+                        "                                        \"" + pack + "\", \"impl\"), \"impl\", \"impl\")",
+                        "--module-source-path", moduleSrc.toString(),
+                        "--default-module-for-created-files=m1x");
+            assertFileExists(classes, "m1x", pack, "impl");
+            assertFileNotExists(classes, "m2x", pack, "impl");
+
+            runCompiler(base,
+                        moduleSrc,
+                        classes,
+                        "doReadResource(() -> filer.getResource(StandardLocation.CLASS_OUTPUT," +
+                        "                                       \"" + pack + "\", \"resource\"), \"1\")",
+                        p -> writeFile("1", p.resolve("m1x"), pack, "resource"),
+                        "--module-source-path", moduleSrc.toString(),
+                        "--default-module-for-created-files=m1x");
+        }
 
-            assertFileExists(classes, "m1x", "api1", "GenApi.class");
-            assertFileExists(classes, "m1x", "impl", "Impl.class");
-            assertFileExists(classes, "m1x", "api1", "gen1");
-            assertFileExists(classes, "m2x", "api2", "GenApi.class");
-            assertFileExists(classes, "m2x", "impl", "Impl.class");
-            assertFileExists(classes, "m2x", "api2", "gen1");
+        //wrong default module:
+        runCompiler(base,
+                    moduleSrc,
+                    classes,
+                    "expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT," +
+                    "                                                \"clash\", \"impl\"))",
+                    "--module-source-path", moduleSrc.toString(),
+                    "--default-module-for-created-files=doesnotexist");
+
+        String[] failingCases = {
+            //must not generate to unnamed package:
+            "expectFilerException(() -> filer.createSourceFile(\"Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"Fail\"))",
+            "expectFilerException(() -> filer.createSourceFile(\"m1x/Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"m1x/Fail\"))",
+
+            //cannot infer module name, package clash:
+            "expectFilerException(() -> filer.createSourceFile(\"clash.Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"clash.Fail\"))",
+            "expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"clash\", \"impl\"))",
+            "expectFilerException(() -> filer.getResource(StandardLocation.CLASS_OUTPUT, \"clash\", \"impl\"))",
+
+            //cannot infer module name, package does not exist:
+            "expectFilerException(() -> filer.createSourceFile(\"doesnotexist.Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"doesnotexist.Fail\"))",
+            "expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"doesnotexist\", \"impl\"))",
+            "expectFilerException(() -> filer.getResource(StandardLocation.CLASS_OUTPUT, \"doesnotexist\", \"impl\"))",
+
+            //cannot generate sources/classes to modules that are not root modules:
+            "expectFilerException(() -> filer.createSourceFile(\"java.base/fail.Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"java.base/fail.Fail\"))",
+
+            //cannot read from module locations if module not given and not inferable:
+            "expectFilerException(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"fail\", \"Fail\"))",
+
+            //wrong module given:
+            "expectException(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"java.compiler/java.lang\", \"Object.class\"))",
+        };
+
+        for (String failingCode : failingCases) {
+            System.err.println("failing code: " + failingCode);
+            runCompiler(base,
+                        moduleSrc,
+                        classes,
+                        failingCode,
+                        "--module-source-path", moduleSrc.toString());
         }
     }
 
-    enum FileType {
-        SOURCE,
-        CLASS;
-    }
-
     public static abstract class GeneratingAP extends AbstractProcessor {
 
-        void createSource(CreateFileObject file, String name, String content) {
+        public void createSource(CreateFileObject file, String name, String content) {
             try (Writer out = file.create().openWriter()) {
                 out.write(content);
             } catch (IOException ex) {
@@ -581,7 +704,7 @@
             }
         }
 
-        void createClass(CreateFileObject file, String name, String content) {
+        public void createClass(CreateFileObject file, String name, String content) {
             String fileNameStub = name.replace(".", File.separator);
 
             try (OutputStream out = file.create().openOutputStream()) {
@@ -617,7 +740,7 @@
             }
         }
 
-        void doReadResource(CreateFileObject file, String expectedContent) {
+        public void doReadResource(CreateFileObject file, String expectedContent) {
             try {
                 StringBuilder actualContent = new StringBuilder();
 
@@ -636,11 +759,19 @@
             }
         }
 
+        public void checkResourceExists(CreateFileObject file) {
+            try {
+                file.create().openInputStream().close();
+            } catch (IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+
         public interface CreateFileObject {
             public FileObject create() throws IOException;
         }
 
-        void expectFilerException(Callable<Object> c) {
+        public void expectFilerException(Callable<Object> c) {
             try {
                 c.call();
                 throw new AssertionError("Expected exception not thrown");
@@ -651,6 +782,17 @@
             }
         }
 
+        public void expectException(Callable<Object> c) {
+            try {
+                c.call();
+                throw new AssertionError("Expected exception not thrown");
+            } catch (IOException ex) {
+                //expected
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+
         @Override
         public SourceVersion getSupportedSourceVersion() {
             return SourceVersion.latest();
@@ -658,167 +800,220 @@
 
     }
 
-    @SupportedAnnotationTypes("*")
-    @SupportedOptions({"filetype", "modulename"})
-    public static final class MultiModeAPITestAP extends GeneratingAP {
-
-        int round;
-
-        @Override
-        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
-            if (round++ != 0)
-                return false;
-
-            createClass("m1x", "api1.GenApi", "package api1; public class GenApi {}");
-            createClass("m1x", "impl.Impl", "package impl; public class Impl {}");
-            createClass("m2x", "api2.GenApi", "package api2; public class GenApi {}");
-            createClass("m2x", "impl.Impl", "package impl; public class Impl {}");
-
-            createResource("m1x", "api1", "gen1");
-            createResource("m2x", "api2", "gen1");
-
-            readResource("m1x", "api1", "api", "1");
-            readResource("m1x", "impl", "impl", "1");
-            readResource("m2x", "api2", "api", "2");
-            readResource("m2x", "impl", "impl", "2");
-
-            Filer filer = processingEnv.getFiler();
-
-            expectFilerException(() -> filer.createSourceFile("fail.Fail"));
-            expectFilerException(() -> filer.createClassFile("fail.Fail"));
-            expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "fail", "fail"));
-            expectFilerException(() -> filer.getResource(StandardLocation.MODULE_SOURCE_PATH, "fail", "fail"));
-
-            //must not generate to unnamed package:
-            expectFilerException(() -> filer.createSourceFile("m1/Fail"));
-            expectFilerException(() -> filer.createClassFile("m1/Fail"));
-
-            //cannot generate resources to modules that are not root modules:
-            expectFilerException(() -> filer.createSourceFile("java.base/fail.Fail"));
-            expectFilerException(() -> filer.createClassFile("java.base/fail.Fail"));
-            expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "java.base/fail", "Fail"));
-
-            return false;
-        }
-
-        void createClass(String expectedModule, String name, String content) {
-            Filer filer = processingEnv.getFiler();
-            FileType filetype = FileType.valueOf(processingEnv.getOptions().getOrDefault("filetype", ""));
-
-            switch (filetype) {
-                case SOURCE:
-                    createSource(() -> filer.createSourceFile(expectedModule + "/" + name), name, content);
-                    break;
-                case CLASS:
-                    createClass(() -> filer.createClassFile(expectedModule + "/" + name), name, content);
-                    break;
-                default:
-                    throw new AssertionError("Unexpected filetype: " + filetype);
-            }
-        }
-
-        void createResource(String expectedModule, String pkg, String relName) {
-            try {
-                Filer filer = processingEnv.getFiler();
-
-                filer.createResource(StandardLocation.CLASS_OUTPUT, expectedModule + "/" + pkg, relName)
-                     .openOutputStream()
-                     .close();
-            } catch (IOException ex) {
-                throw new IllegalStateException(ex);
-            }
-        }
-
-        void readResource(String expectedModule, String pkg, String relName, String expectedContent) {
-            Filer filer = processingEnv.getFiler();
-
-            doReadResource(() -> filer.getResource(StandardLocation.MODULE_SOURCE_PATH, expectedModule + "/" + pkg, relName),
-                           expectedContent);
-        }
-
-    }
-
     @Test
-    public void testGenerateInSingleNameModeAPI(Path base) throws Exception {
+    public void testGenerateSingleModule(Path base) throws Exception {
         Path classes = base.resolve("classes");
 
         Files.createDirectories(classes);
 
-        Path m1 = base.resolve("module-src");
+        Path src = base.resolve("module-src");
+        Path m1 = src.resolve("m1x");
 
         tb.writeJavaFiles(m1,
-                          "module m1x { }");
+                          "module m1x { }",
+                          "package test; class Test { impl.Impl i; }");
+        Path m2 = src.resolve("m2x");
 
-        writeFile("3", m1, "impl", "resource");
+        tb.writeJavaFiles(m2,
+                          "module m2x { }");
 
-        new JavacTask(tb)
-          .options("-processor", SingleNameModeAPITestAP.class.getName(),
-                   "-sourcepath", m1.toString())
-          .outdir(classes)
-          .files(findJavaFiles(m1))
-          .run()
-          .writeAll();
+        for (String[] options : new String[][] {new String[] {"-sourcepath", m1.toString()},
+                                                new String[] {"--module-source-path", src.toString()}}) {
+            String modulePath = options[0].equals("--module-source-path") ? "m1x" : "";
+            //passing testcases:
+            for (String module : Arrays.asList("", "m1x/")) {
+                for (String originating : Arrays.asList("", ", jlObject")) {
+                    tb.writeJavaFiles(m1,
+                                      "package test; class Test { impl.Impl i; }");
 
-        assertFileExists(classes, "impl", "Impl1.class");
-        assertFileExists(classes, "impl", "Impl2.class");
-        assertFileExists(classes, "impl", "Impl3");
-        assertFileExists(classes, "impl", "Impl4.class");
-        assertFileExists(classes, "impl", "Impl5.class");
-        assertFileExists(classes, "impl", "Impl6");
-        assertFileExists(classes, "impl", "Impl7.class");
-        assertFileExists(classes, "impl", "Impl8.class");
-        assertFileExists(classes, "impl", "Impl9");
-    }
+                    //source:
+                    runCompiler(base,
+                                m1,
+                                classes,
+                                "createSource(() -> filer.createSourceFile(\"" + module + "impl.Impl\"" + originating + "), \"impl.Impl\", \"package impl; public class Impl {}\")",
+                                options);
+                    assertFileExists(classes, modulePath, "impl", "Impl.class");
 
+                    //class:
+                    runCompiler(base,
+                                m1,
+                                classes,
+                                "createClass(() -> filer.createClassFile(\"" + module + "impl.Impl\"" + originating + "), \"impl.Impl\", \"package impl; public class Impl {}\")",
+                                options);
+                    assertFileExists(classes, modulePath, "impl", "Impl.class");
 
-    @SupportedAnnotationTypes("*")
-    public static final class SingleNameModeAPITestAP extends GeneratingAP {
+                    Files.delete(m1.resolve("test").resolve("Test.java"));
 
-        int round;
-
-        @Override
-        public synchronized void init(ProcessingEnvironment processingEnv) {
-            super.init(processingEnv);
+                    //resource class output:
+                    runCompiler(base,
+                                m1,
+                                classes,
+                                "createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"impl\", \"impl\"" + originating + "), \"impl\", \"impl\")",
+                                options);
+                    assertFileExists(classes, modulePath, "impl", "impl");
+                }
+            }
         }
 
-        @Override
-        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
-            if (round++ != 0)
-                return false;
+        //get resource source path:
+        writeFile("1", m1, "impl", "resource");
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "doReadResource(() -> filer.getResource(StandardLocation.SOURCE_PATH, \"impl\", \"resource\"), \"1\")",
+                    "-sourcepath", m1.toString());
+        //must not specify module when reading non-module oriented locations:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "expectFilerException(() -> filer.getResource(StandardLocation.SOURCE_PATH, \"m1x/impl\", \"resource\"))",
+                    "-sourcepath", m1.toString());
 
-            Filer filer = processingEnv.getFiler();
+        Files.delete(m1.resolve("impl").resolve("resource"));
 
-            createSource(() -> filer.createSourceFile("impl.Impl1"), "impl.Impl1", "package impl; class Impl1 {}");
-            createClass(() -> filer.createClassFile("impl.Impl2"), "impl.Impl2", "package impl; class Impl2 {}");
-            createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "impl", "Impl3"), "impl.Impl3", "");
-            doReadResource(() -> filer.getResource(StandardLocation.SOURCE_PATH, "impl", "resource"), "3");
+        //can read resources from the system module path if module name given:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "checkResourceExists(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"java.base/java.lang\", \"Object.class\"))",
+                    "-sourcepath", m1.toString());
 
-            createSource(() -> filer.createSourceFile("m1x/impl.Impl4"), "impl.Impl4", "package impl; class Impl4 {}");
-            createClass(() -> filer.createClassFile("m1x/impl.Impl5"), "impl.Impl5", "package impl; class Impl5 {}");
-            createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "m1x/impl", "Impl6"), "impl.Impl6", "");
-            doReadResource(() -> filer.getResource(StandardLocation.SOURCE_PATH, "m1x/impl", "resource"), "3");
+        //can read resources from the system module path if module inferable:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "expectFilerException(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"java.lang\", \"Object.class\"))",
+                    "-sourcepath", m1.toString());
+
+        //cannot generate resources to modules that are not root modules:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"java.base/fail\", \"Fail\"))",
+                    "--module-source-path", src.toString());
 
-            TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");
+        //can generate resources to the single root module:
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"impl\", \"impl\"), \"impl\", \"impl\")",
+                    "--module-source-path", src.toString());
+        assertFileExists(classes, "m1x", "impl", "impl");
 
-            //"broken" originating element:
-            createSource(() -> filer.createSourceFile("impl.Impl7", jlObject), "impl.Impl7", "package impl; class Impl7 {}");
-            createClass(() -> filer.createClassFile("impl.Impl8", jlObject), "impl.Impl8", "package impl; class Impl8 {}");
-            createSource(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "impl", "Impl9", jlObject), "impl.Impl9", "");
-
+        String[] failingCases = {
             //must not generate to unnamed package:
-            expectFilerException(() -> filer.createSourceFile("Fail"));
-            expectFilerException(() -> filer.createClassFile("Fail"));
-            expectFilerException(() -> filer.createSourceFile("m1x/Fail"));
-            expectFilerException(() -> filer.createClassFile("m1x/Fail"));
+            "expectFilerException(() -> filer.createSourceFile(\"Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"Fail\"))",
+            "expectFilerException(() -> filer.createSourceFile(\"m1x/Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"m1x/Fail\"))",
+
+            //cannot generate sources/classes to modules that are not root modules:
+            "expectFilerException(() -> filer.createSourceFile(\"java.base/fail.Fail\"))",
+            "expectFilerException(() -> filer.createClassFile(\"java.base/fail.Fail\"))",
+
+            //cannot specify module name for class output when not in the multi-module mode:
+            "expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, \"m1x/fail\", \"Fail\"))",
 
-            //cannot generate resources to modules that are not root modules:
-            expectFilerException(() -> filer.createSourceFile("java.base/fail.Fail"));
-            expectFilerException(() -> filer.createClassFile("java.base/fail.Fail"));
-            expectFilerException(() -> filer.createResource(StandardLocation.CLASS_OUTPUT, "java.base/fail", "Fail"));
+            //cannot read from module locations if module not given:
+            "expectFilerException(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"fail\", \"Fail\"))",
+
+            //wrong module given:
+            "expectException(() -> filer.getResource(StandardLocation.SYSTEM_MODULES, \"java.compiler/java.lang\", \"Object.class\"))",
+        };
 
-            return false;
+        for (String failingCode : failingCases) {
+            System.err.println("failing code: " + failingCode);
+            runCompiler(base,
+                        m1,
+                        classes,
+                        failingCode,
+                        "-sourcepath", m1.toString());
         }
 
+        Files.delete(m1.resolve("module-info.java"));
+        tb.writeJavaFiles(m1,
+                          "package test; class Test { }");
+
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "expectFilerException(() -> filer.createSourceFile(\"m1x/impl.Impl\"))",
+                    "-sourcepath", m1.toString(),
+                    "-source", "8");
+
+        runCompiler(base,
+                    m1,
+                    classes,
+                    "expectFilerException(() -> filer.createClassFile(\"m1x/impl.Impl\"))",
+                    "-sourcepath", m1.toString(),
+                    "-source", "8");
+    }
+
+    private void runCompiler(Path base, Path src, Path classes,
+                             String code, String... options) throws IOException {
+        runCompiler(base, src, classes, code, p -> {}, options);
+    }
+
+    private void runCompiler(Path base, Path src, Path classes,
+                             String code, Consumer<Path> generateToClasses,
+                             String... options) throws IOException {
+        Path apClasses = base.resolve("ap-classes");
+        if (Files.exists(apClasses)) {
+            tb.cleanDirectory(apClasses);
+        } else {
+            Files.createDirectories(apClasses);
+        }
+        compileAP(apClasses, code);
+        if (Files.exists(classes)) {
+            tb.cleanDirectory(classes);
+        } else {
+            Files.createDirectories(classes);
+        }
+        generateToClasses.accept(classes);
+        List<String> opts = new ArrayList<>();
+        opts.addAll(Arrays.asList(options));
+        opts.add("-processorpath");
+        opts.add(System.getProperty("test.class.path") + File.pathSeparator + apClasses.toString());
+        opts.add("-processor");
+        opts.add("AP");
+        new JavacTask(tb)
+          .options(opts)
+          .outdir(classes)
+          .files(findJavaFiles(src))
+          .run()
+          .writeAll();
+    }
+
+    private void compileAP(Path target, String code) {
+        String processorCode =
+            "import java.util.*;\n" +
+            "import javax.annotation.processing.*;\n" +
+            "import javax.lang.model.*;\n" +
+            "import javax.lang.model.element.*;\n" +
+            "import javax.lang.model.type.*;\n" +
+            "import javax.lang.model.util.*;\n" +
+            "import javax.tools.*;\n" +
+            "@SupportedAnnotationTypes(\"*\")\n" +
+            "public final class AP extends AnnotationProcessing.GeneratingAP {\n" +
+            "\n" +
+            "        int round;\n" +
+            "\n" +
+            "        @Override\n" +
+            "        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {\n" +
+            "            if (round++ != 0)\n" +
+            "                return false;\n" +
+            "            Filer filer = processingEnv.getFiler();\n" +
+            "            TypeElement jlObject = processingEnv.getElementUtils().getTypeElement(\"java.lang.Object\");\n" +
+            code + ";\n" +
+            "            return false;\n" +
+            "        }\n" +
+            "    }\n";
+        new JavacTask(tb)
+          .options("-classpath", System.getProperty("test.class.path"))
+          .sources(processorCode)
+          .outdir(target)
+          .run()
+          .writeAll();
     }
 
     @Test
@@ -1089,13 +1284,17 @@
 
     }
 
-    private static void writeFile(String content, Path base, String... pathElements) throws IOException {
-        Path file = resolveFile(base, pathElements);
+    private static void writeFile(String content, Path base, String... pathElements) {
+        try {
+            Path file = resolveFile(base, pathElements);
+
+            Files.createDirectories(file.getParent());
 
-        Files.createDirectories(file.getParent());
-
-        try (Writer out = Files.newBufferedWriter(file)) {
-            out.append(content);
+            try (Writer out = Files.newBufferedWriter(file)) {
+                out.append(content);
+            }
+        } catch (IOException ex) {
+            throw new UncheckedIOException(ex);
         }
     }
 
@@ -1286,6 +1485,35 @@
 
     }
 
+    @Test
+    public void testWrongDefaultTargetModule(Path base) throws Exception {
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src,
+                          "package test; public class Test { }");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+            .options("--default-module-for-created-files=m!",
+                     "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+            "- compiler.err.bad.name.for.option: --default-module-for-created-files, m!"
+        );
+
+        if (!log.equals(expected)) {
+            throw new AssertionError("Expected output not found.");
+        }
+    }
+
     private static void assertNonNull(String msg, Object val) {
         if (val == null) {
             throw new AssertionError(msg);
@@ -1312,6 +1540,14 @@
         }
     }
 
+    private static void assertFileNotExists(Path base, String... pathElements) {
+        Path file = resolveFile(base, pathElements);
+
+        if (Files.exists(file)) {
+            throw new AssertionError("Expected file: " + file + " exist, but it does not.");
+        }
+    }
+
     static Path resolveFile(Path base, String... pathElements) {
         Path file = base;
 
--- a/langtools/test/tools/javac/modules/CompileModulePatchTest.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/tools/javac/modules/CompileModulePatchTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -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
@@ -180,7 +180,9 @@
 
         List<String> expectedOut = Arrays.asList(
                 "Test.java:1:1: compiler.err.file.patched.and.msp: m1x, m2x",
-                "1 error"
+                "module-info.java:1:1: compiler.err.module.name.mismatch: m2x, m1x",
+                "- compiler.err.cant.access: m1x.module-info, (compiler.misc.cant.resolve.modules)",
+                "3 errors"
         );
 
         if (!expectedOut.equals(log))
@@ -259,112 +261,6 @@
     }
 
     @Test
-    public void testNoModuleInfoOnSourcePath(Path base) throws Exception {
-        //note: avoiding use of java.base, as that gets special handling on some places:
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src,
-                          "module java.compiler {}",
-                          "package javax.lang.model.element; public interface Extra { }");
-        Path classes = base.resolve("classes");
-        tb.createDirectories(classes);
-
-        List<String> log;
-        List<String> expected;
-
-        log = new JavacTask(tb)
-                .options("-XDrawDiagnostics",
-                         "--patch-module", "java.compiler=" + src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.patched.module.sourcepath",
-                                 "1 error");
-
-        if (!expected.equals(log))
-            throw new Exception("expected output not found: " + log);
-
-        //multi-module mode:
-        log = new JavacTask(tb)
-                .options("-XDrawDiagnostics",
-                         "--patch-module", "java.compiler=" + src.toString(),
-                         "--module-source-path", "dummy")
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        expected = Arrays.asList("- compiler.err.locn.module-info.not.allowed.on.patch.path: module-info.java",
-                                 "1 error");
-
-        if (!expected.equals(log))
-            throw new Exception("expected output not found: " + log);
-    }
-
-    @Test
-    public void testNoModuleInfoInClassOutput(Path base) throws Exception {
-        //note: avoiding use of java.base, as that gets special handling on some places:
-        Path srcMod = base.resolve("src-mod");
-        tb.writeJavaFiles(srcMod,
-                          "module mod {}");
-        Path classes = base.resolve("classes").resolve("java.compiler");
-        tb.createDirectories(classes);
-
-        String logMod = new JavacTask(tb)
-                .options()
-                .outdir(classes)
-                .files(findJavaFiles(srcMod))
-                .run()
-                .writeAll()
-                .getOutput(Task.OutputKind.DIRECT);
-
-        if (!logMod.isEmpty())
-            throw new Exception("unexpected output found: " + logMod);
-
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src,
-                          "package javax.lang.model.element; public interface Extra { }");
-        tb.createDirectories(classes);
-
-        List<String> log;
-        List<String> expected;
-
-        log = new JavacTask(tb)
-                .options("-XDrawDiagnostics",
-                         "--patch-module", "java.compiler=" + src.toString())
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.patched.module.classoutput",
-                                 "1 error");
-
-        if (!expected.equals(log))
-            throw new Exception("expected output not found: " + log);
-
-        log = new JavacTask(tb)
-                .options("-XDrawDiagnostics",
-                         "--patch-module", "java.compiler=" + src.toString(),
-                         "--module-source-path", "dummy")
-                .outdir(classes.getParent())
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        expected = Arrays.asList("- compiler.err.locn.module-info.not.allowed.on.patch.path: module-info.class",
-                                 "1 error");
-
-        if (!expected.equals(log))
-            throw new Exception("expected output not found: " + log);
-    }
-
-    @Test
     public void testWithModulePath(Path base) throws Exception {
         Path modSrc = base.resolve("modSrc");
         Path modules = base.resolve("modules");
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8154283 8167320 8171098 8172809 8173068 8173117
+ * @bug 8154283 8167320 8171098 8172809 8173068 8173117 8176045 8177311
  * @summary tests for multi-module mode compilation
  * @library /tools/lib
  * @modules
@@ -36,6 +36,7 @@
  * @run main EdgeCases
  */
 
+import java.io.BufferedWriter;
 import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -67,10 +68,7 @@
 //import com.sun.source.util.JavacTask; // conflicts with toolbox.JavacTask
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
-import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import com.sun.tools.javac.util.Context;
 
 import toolbox.JarTask;
 import toolbox.JavacTask;
@@ -269,13 +267,22 @@
         Path classes = base.resolve("classes");
         tb.createDirectories(classes);
 
-        new JavacTask(tb)
+        List<String> log = new JavacTask(tb)
                 .options("--source-path", src_m1.toString(),
                          "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(src_m1.resolve("test")))
                 .run(Task.Expect.FAIL)
-                .writeAll();
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "- compiler.err.cant.access: module-info, (compiler.misc.bad.source.file.header: module-info.java, (compiler.misc.file.does.not.contain.module))",
+                "1 error");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
 
         tb.writeJavaFiles(src_m1,
                           "module m1x {}");
@@ -812,4 +819,180 @@
         }
 
     }
+
+    @Test
+    public void testEmptyInExportedPackage(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m = src.resolve("m");
+        tb.writeJavaFiles(m,
+                          "module m { exports api; }");
+        Path apiFile = m.resolve("api").resolve("Api.java");
+        Files.createDirectories(apiFile.getParent());
+        try (BufferedWriter w = Files.newBufferedWriter(apiFile)) {
+            w.write("//no package decl");
+        }
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log;
+        List<String> expected =
+                Arrays.asList("module-info.java:1:20: compiler.err.package.empty.or.not.found: api",
+                              "1 error");
+
+        System.err.println("file explicitly specified:");
+
+        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);
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found: " + log);
+
+        System.err.println("file not specified:");
+
+        tb.cleanDirectory(classes);
+
+        log = new JavacTask(tb)
+            .options("-XDrawDiagnostics",
+                     "--module-source-path", src.toString())
+            .outdir(classes)
+            .files(findJavaFiles(m.resolve("module-info.java")))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found: " + log);
+    }
+
+    @Test
+    public void testJustPackageInExportedPackage(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m = src.resolve("m");
+        tb.writeJavaFiles(m,
+                          "module m { exports api; }");
+        Path apiFile = m.resolve("api").resolve("Api.java");
+        Files.createDirectories(apiFile.getParent());
+        try (BufferedWriter w = Files.newBufferedWriter(apiFile)) {
+            w.write("package api;");
+        }
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        System.err.println("file explicitly specified:");
+
+        new JavacTask(tb)
+            .options("-XDrawDiagnostics",
+                     "--module-source-path", src.toString())
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll();
+
+        System.err.println("file not specified:");
+
+        tb.cleanDirectory(classes);
+
+        new JavacTask(tb)
+            .options("-XDrawDiagnostics",
+                     "--module-source-path", src.toString())
+            .outdir(classes)
+            .files(findJavaFiles(m.resolve("module-info.java")))
+            .run()
+            .writeAll();
+    }
+
+    @Test
+    public void testWrongPackageInExportedPackage(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m = src.resolve("m");
+        tb.writeJavaFiles(m,
+                          "module m { exports api; }");
+        Path apiFile = m.resolve("api").resolve("Api.java");
+        Files.createDirectories(apiFile.getParent());
+        try (BufferedWriter w = Files.newBufferedWriter(apiFile)) {
+            w.write("package impl; public class Api { }");
+        }
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log;
+
+        List<String> expected =
+                Arrays.asList("module-info.java:1:20: compiler.err.package.empty.or.not.found: api",
+                              "1 error");
+
+        System.err.println("file explicitly specified:");
+
+        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);
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found: " + log);
+
+        System.err.println("file not specified:");
+
+        tb.cleanDirectory(classes);
+
+        log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(m.resolve("module-info.java")))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found: " + log);
+    }
+
+    @Test
+    public void testDependOnUnnamedAccessibility(Path base) throws Exception {
+        Path unnamedSrc = base.resolve("unnamed-src");
+        tb.writeJavaFiles(unnamedSrc,
+                          "package p1; public class First { public static p2.Second get() { return null; } }",
+                          "package p2; public class Second { public void test() { } }");
+        Path unnamedClasses = base.resolve("unnamed-classes");
+        tb.createDirectories(unnamedClasses);
+
+        System.err.println("compiling unnamed sources:");
+
+        new JavacTask(tb)
+                .outdir(unnamedClasses)
+                .files(findJavaFiles(unnamedSrc))
+                .run()
+                .writeAll();
+
+        //test sources:
+        Path src = base.resolve("src");
+        Path m = src.resolve("m");
+        tb.writeJavaFiles(m,
+                          "module m { }",
+                          "package p; public class Test { { p1.First.get().test(); } }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        System.err.println("compiling test module:");
+
+        new JavacTask(tb)
+            .options("-classpath", unnamedClasses.toString(),
+                     "--add-reads", "m=ALL-UNNAMED")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll();
+    }
+
 }
--- a/langtools/test/tools/javac/modules/MOptionTest.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/tools/javac/modules/MOptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8146946
+ * @bug 8146946 8176743
  * @summary implement javac -m option
  * @library /tools/lib
  * @modules
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/ModuleInfoPatchPath.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 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 8175057
+ * @summary Verify that having module-info on patch path works correctly.
+ * @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.processing
+ *      jdk.compiler/com.sun.tools.javac.util
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
+ * @run main ModuleInfoPatchPath
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.Task.OutputKind;
+
+public class ModuleInfoPatchPath extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new ModuleInfoPatchPath().runTests();
+    }
+
+    @Test
+    public void testModuleInfoToModulePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "module m { exports api; }",
+                          "package api; public class Api {}");
+        Path patch = base.resolve("patch");
+        tb.writeJavaFiles(patch,
+                          "module m { requires java.compiler; exports api; }",
+                          "package api; public class Api { public static javax.lang.model.element.Element element; }");
+        Path classes = base.resolve("classes");
+        Path mClasses = classes.resolve("m");
+        tb.createDirectories(mClasses);
+
+        System.err.println("Building the vanilla module...");
+
+        new JavacTask(tb)
+            .outdir(mClasses)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll();
+
+        Path test = base.resolve("test");
+        tb.writeJavaFiles(test,
+                          "module test { requires m; }",
+                          "package test; public class Test { private void test() { api.Api.element = null; } }");
+
+        Path testClasses = classes.resolve("test");
+        tb.createDirectories(testClasses);
+
+        System.err.println("Building patched module...");
+
+        new JavacTask(tb)
+            .options("--module-path", mClasses.toString(),
+                     "--patch-module", "m=" + patch.toString())
+            .outdir(testClasses)
+            .files(findJavaFiles(test))
+            .run()
+            .writeAll();
+
+        Path patchClasses = classes.resolve("patch");
+        tb.createDirectories(patchClasses);
+
+        System.err.println("Building patch...");
+
+        new JavacTask(tb)
+            .outdir(patchClasses)
+            .files(findJavaFiles(patch))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(testClasses);
+
+        Files.delete(patch.resolve("module-info.java"));
+        Files.copy(patchClasses.resolve("module-info.class"), patch.resolve("module-info.class"));
+
+        System.err.println("Building patched module against binary patch...");
+
+        new JavacTask(tb)
+            .options("--module-path", mClasses.toString(),
+                     "--patch-module", "m=" + patch.toString())
+            .outdir(testClasses)
+            .files(findJavaFiles(test))
+            .run()
+            .writeAll();
+    }
+
+    @Test
+    public void testModuleInfoToSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "module m { exports api; }",
+                          "package api; public class Api {}",
+                          "package test; public class Test { private void test() { api.Api.element = null; } }");
+        Path patch = base.resolve("patch");
+        tb.writeJavaFiles(patch,
+                          "module m { requires java.compiler; exports api; }",
+                          "package api; public class Api { public static javax.lang.model.element.Element element; }");
+        Path classes = base.resolve("classes");
+        Path mClasses = classes.resolve("m");
+        tb.createDirectories(mClasses);
+
+        System.err.println("Building patched module against source patch...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "-sourcepath", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(src.resolve("test")))
+            .run()
+            .writeAll();
+
+        //incremental compilation:
+        List<String> log;
+
+        System.err.println("Incremental building of patched module against source patch, no module-info...");
+
+        log = new JavacTask(tb)
+                .options("--patch-module", "m=" + patch.toString(),
+                         "-sourcepath", src.toString(),
+                         "-verbose")
+                .outdir(mClasses)
+                .files(findJavaFiles(src.resolve("test")))
+                .run()
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        if (log.stream().filter(line -> line.contains("[parsing started")).count() != 1) {
+            throw new AssertionError("incorrect number of parsing events.");
+        }
+
+        System.err.println("Incremental building of patched module against source patch, with module-info...");
+
+        log = new JavacTask(tb)
+                .options("--patch-module", "m=" + patch.toString(),
+                         "-sourcepath", src.toString(),
+                         "-verbose")
+                .outdir(mClasses)
+                .files(findJavaFiles(patch.resolve("module-info.java"), src.resolve("test")))
+                .run()
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        if (log.stream().filter(line -> line.contains("[parsing started")).count() != 2) {
+            throw new AssertionError("incorrect number of parsing events.");
+        }
+
+        tb.cleanDirectory(mClasses);
+
+        System.err.println("Building patched module against source patch with source patch on patch path...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "-sourcepath", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(src.resolve("test"), patch))
+            .run()
+            .writeAll();
+
+        Path patchClasses = classes.resolve("patch");
+        tb.createDirectories(patchClasses);
+
+        System.err.println("Building patch...");
+
+        new JavacTask(tb)
+            .outdir(patchClasses)
+            .files(findJavaFiles(patch))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(mClasses);
+
+        Files.delete(patch.resolve("module-info.java"));
+        Files.copy(patchClasses.resolve("module-info.class"), patch.resolve("module-info.class"));
+
+        System.err.println("Building patched module against binary patch...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "-sourcepath", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(src.resolve("test")))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(mClasses);
+
+        System.err.println("Building patched module against binary patch with source patch on patch path...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "-sourcepath", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(src.resolve("test"), patch))
+            .run()
+            .writeAll();
+    }
+
+    @Test
+    public void testModuleInfoToModuleSourcePath(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m = src.resolve("m");
+        tb.writeJavaFiles(m,
+                          "module m { exports api; }",
+                          "package api; public class Api {}",
+                          "package test; public class Test { private void test() { api.Api.element = null; } }");
+        Path patch = base.resolve("patch");
+        tb.writeJavaFiles(patch,
+                          "module m { requires java.compiler; exports api; }",
+                          "package api; public class Api { public static javax.lang.model.element.Element element; }");
+        Path classes = base.resolve("classes");
+        Path mClasses = classes.resolve("m");
+        tb.createDirectories(mClasses);
+
+        System.err.println("Building patched module against source patch...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "--module-source-path", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(m.resolve("test")))
+            .run()
+            .writeAll();
+
+        //incremental compilation:
+
+        System.err.println("Incremental building of patched module against source patch...");
+
+        List<String> log = new JavacTask(tb)
+                .options("--patch-module", "m=" + patch.toString(),
+                         "--module-source-path", src.toString(),
+                         "-verbose")
+                .outdir(mClasses)
+                .files(findJavaFiles(m.resolve("test")))
+                .run()
+                .writeAll()
+                .getOutputLines(OutputKind.DIRECT);
+
+        if (log.stream().filter(line -> line.contains("[parsing started")).count() != 1) {
+            throw new AssertionError("incorrect number of parsing events.");
+        }
+
+        tb.cleanDirectory(mClasses);
+
+        System.err.println("Building patched module against source patch with source patch on patch path...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "--module-source-path", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(m.resolve("test"), patch))
+            .run()
+            .writeAll();
+
+        Path patchClasses = classes.resolve("patch");
+        tb.createDirectories(patchClasses);
+
+        System.err.println("Building patch...");
+
+        new JavacTask(tb)
+            .outdir(patchClasses)
+            .files(findJavaFiles(patch))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(mClasses);
+
+        Files.delete(patch.resolve("module-info.java"));
+        Files.copy(patchClasses.resolve("module-info.class"), patch.resolve("module-info.class"));
+
+        System.err.println("Building patched module against binary patch...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "--module-source-path", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(m.resolve("test")))
+            .run()
+            .writeAll();
+
+        tb.cleanDirectory(mClasses);
+
+        System.err.println("Building patched module against binary patch with source patch on patch path...");
+
+        new JavacTask(tb)
+            .options("--patch-module", "m=" + patch.toString(),
+                     "--module-source-path", src.toString())
+            .outdir(mClasses)
+            .files(findJavaFiles(m.resolve("test"), patch))
+            .run()
+            .writeAll();
+    }
+
+}
--- a/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jul 05 23:09:24 2017 +0200
+++ b/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -281,7 +281,7 @@
         JavacTool tool = JavacTool.create();
         r.errors = 0;
         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
-        JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
+        JavacTask task = tool.getTask(pw, fm, r, List.of("-proc:none"), null, files);
         Iterable<? extends CompilationUnitTree> trees = task.parse();
         pw.flush();
         if (r.errors > 0)