Merge
authorlana
Thu, 16 Mar 2017 17:56:00 +0000
changeset 44298 91f4062cbbc2
parent 44232 e410da6abe85 (current diff)
parent 44297 e03f5fb3714b (diff)
child 44299 f7ba265fafc7
Merge
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/ModuleInfoWithPatchedModuleClassoutput.java
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/additional/module-info.java
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/patchmodule/java.compiler/javax/lang/model/element/Extra.java
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/ModuleInfoWithPatchedModule.java
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/javax/lang/model/element/Extra.java
langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/module-info.java
--- a/langtools/src/java.compiler/share/classes/javax/annotation/processing/Filer.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Filer.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/Infer.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 16 17:56:00 2017 +0000
@@ -190,28 +190,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 +319,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 +339,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)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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)
@@ -408,9 +410,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;
@@ -460,7 +471,6 @@
                                 defaultModule.classLocation = StandardLocation.CLASS_PATH;
                             }
                         } else {
-                            checkSpecifiedModule(trees, moduleOverride, Errors.ModuleInfoWithPatchedModuleClassoutput);
                             checkNoAllModulePath();
                             defaultModule.complete();
                             // Question: why not do completeModule here?
@@ -470,18 +480,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);
@@ -562,17 +584,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);
@@ -703,6 +714,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<>();
@@ -947,7 +963,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);
@@ -1667,4 +1706,8 @@
         rootModules = null;
         warnedMissing.clear();
     }
+
+    public interface PackageNameFinder {
+        public Name findPackageNameOf(JavaFileObject jfo);
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Thu Mar 16 17:56:00 2017 +0000
@@ -614,6 +614,7 @@
         validateAddModules(sv);
         validateAddReads(sv);
         validateLimitModules(sv);
+        validateDefaultModuleForCreatedFiles(sv);
 
         if (lintOptions && options.isSet(Option.ADD_OPENS)) {
             log.warning(LintCategory.OPTIONS, Warnings.AddopensIgnored);
@@ -751,6 +752,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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Mar 16 17:56:00 2017 +0000
@@ -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.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/Contents.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/ModuleWriterImpl.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Thu Mar 16 17:56:00 2017 +0000
@@ -441,6 +441,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()) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/ToolEnvironment.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Thu Mar 16 17:56:00 2017 +0000
@@ -278,7 +278,6 @@
 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}"
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Thu Mar 16 17:56:00 2017 +0000
@@ -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/test/jdk/javadoc/doclet/testClassLinks/TestClassLinks.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassLinks/TestClassLinks.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassTree/pkg/Coin.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testConstructors/TestConstructors.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testIndentation/TestIndentation.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/testLiteralCodeInPre/TestLiteralCodeInPre.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationType.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleB/testpkgmdlB/AnnotationTypeUndocumented.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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>"
         );
 
--- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Receivers.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/tool/IgnoreSourceErrors.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/T6551367.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/badSuper/BadSuper.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 17:56:00 2017 +0000
@@ -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:");
+    }
+
+}
--- a/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Thu Mar 16 17:56:00 2017 +0000
@@ -180,11 +180,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);
     }
 
--- a/langtools/test/jdk/javadoc/tool/modules/Modules.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/Modules.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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
@@ -525,7 +525,7 @@
                 "--module", "MIA",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found.");
+        assertMessagePresent("javadoc: error - module MIA not found.");
     }
 
     @Test
@@ -547,7 +547,7 @@
                 "--module", "M,N,L,MIA,O,P",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found");
+        assertMessagePresent("javadoc: error - module MIA not found");
     }
 
     void createAuxiliaryModules(Path src) throws IOException {
--- a/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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
--- a/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/outputRedirect/p/OutputRedirect.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/ModuleInfoWithPatchedModuleClassoutput.java	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 16:34:37 2017 +0000
+++ /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	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 17:56:00 2017 +0000
@@ -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());
+        }
+    }
+}
--- a/langtools/test/tools/javac/modules/AnnotationProcessing.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/tools/javac/modules/CompileModulePatchTest.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Thu Mar 16 17:56:00 2017 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8154283 8167320 8171098 8172809 8173068 8173117
+ * @bug 8154283 8167320 8171098 8172809 8173068 8173117 8176045
  * @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,143 @@
         }
 
     }
+
+    @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);
+    }
+
 }
--- a/langtools/test/tools/javac/modules/MOptionTest.java	Thu Mar 16 16:34:37 2017 +0000
+++ b/langtools/test/tools/javac/modules/MOptionTest.java	Thu Mar 16 17:56:00 2017 +0000
@@ -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	Thu Mar 16 17:56:00 2017 +0000
@@ -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();
+    }
+
+}