changeset 49120:ffa68af7da87

8195795: Organize output files by module/package, not just package Reviewed-by: ksrini, mchung, erikj
author jjg
date Wed, 07 Feb 2018 11:28:23 -0800
parents ba19a21d727d
children 25725c11c296
files make/Docs.gmk make/jdk/src/classes/build/tools/taglet/ModuleGraph.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java test/langtools/jdk/javadoc/doclet/testModules/TestIndirectExportsOpens.java test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java test/langtools/jdk/javadoc/doclet/testModules/TestModules.java test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java
diffstat 36 files changed, 579 insertions(+), 376 deletions(-) [+]
line wrap: on
line diff
--- a/make/Docs.gmk	Wed Feb 07 09:48:43 2018 -0800
+++ b/make/Docs.gmk	Wed Feb 07 11:28:23 2018 -0800
@@ -1,4 +1,4 @@
-# Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2018, 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
@@ -200,7 +200,7 @@
 #
 define setup_gengraph_dot_to_png
   $1_$2_DOT_SRC :=  $$($1_GENGRAPHS_DIR)/$2.dot
-  $1_$2_PNG_TARGET := $$($1_TARGET_DIR)/$2-graph.png
+  $1_$2_PNG_TARGET := $$($1_TARGET_DIR)/$2/module-graph.png
 
     # For each module needing a graph, create a png file from the dot file
     # generated by the GenGraphs tool and store it in the target dir.
--- a/make/jdk/src/classes/build/tools/taglet/ModuleGraph.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/make/jdk/src/classes/build/tools/taglet/ModuleGraph.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -64,7 +64,7 @@
         }
 
         String moduleName = ((ModuleElement) element).getQualifiedName().toString();
-        String imageFile = moduleName + "-graph.png";
+        String imageFile = moduleName + "/module-graph.png";
         int thumbnailHeight = -1;
         String hoverImage = "";
         if (!moduleName.equals("java.base")) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -75,7 +75,7 @@
      */
     public AnnotationTypeWriterImpl(HtmlConfiguration configuration,
             TypeElement annotationType) {
-        super(configuration, DocPath.forClass(configuration.utils, annotationType));
+        super(configuration, configuration.docPaths.forClass(annotationType));
         this.annotationType = annotationType;
         configuration.currentTypeElement = annotationType;
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -233,9 +233,9 @@
     public static void generate(HtmlConfiguration configuration, ClassUseMapper mapper,
                                 TypeElement typeElement) throws DocFileIOException {
         ClassUseWriter clsgen;
-        DocPath path = DocPath.forPackage(configuration.utils, typeElement)
+        DocPath path = configuration.docPaths.forPackage(typeElement)
                               .resolve(DocPaths.CLASS_USE)
-                              .resolve(DocPath.forName(configuration.utils, typeElement));
+                              .resolve(configuration.docPaths.forName( typeElement));
         clsgen = new ClassUseWriter(configuration, mapper, path, typeElement);
         clsgen.generateClassUseFile();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -85,7 +85,7 @@
      */
     public ClassWriterImpl(HtmlConfiguration configuration, TypeElement typeElement,
                            ClassTree classTree) {
-        super(configuration, DocPath.forClass(configuration.utils, typeElement));
+        super(configuration, configuration.docPaths.forClass(typeElement));
         this.typeElement = typeElement;
         configuration.currentTypeElement = typeElement;
         this.classtree = classTree;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -74,12 +74,18 @@
 
         switch (element.getKind()) {
             case MODULE:
-                location = configuration.utils.getLocationForModule((ModuleElement)element);
+                ModuleElement mdle = (ModuleElement)element;
+                location = configuration.utils.getLocationForModule(mdle);
                 source = DocPaths.DOC_FILES;
                 break;
             case PACKAGE:
-                location = configuration.utils.getLocationForPackage((PackageElement)element);
-                source = DocPath.forPackage((PackageElement)element).resolve(DocPaths.DOC_FILES);
+                PackageElement pkg = (PackageElement)element;
+                location = configuration.utils.getLocationForPackage(pkg);
+                // Note, given that we have a module-specific location,
+                // we want a module-relative path for the source, and not the
+                // standard path that may include the module directory
+                source = DocPath.create(pkg.getQualifiedName().toString().replace('.', '/'))
+                        .resolve(DocPaths.DOC_FILES);
                 break;
             default:
                 throw new AssertionError("unsupported element " + element);
@@ -103,10 +109,10 @@
             DocPath path = null;
             switch (this.element.getKind()) {
                 case MODULE:
-                    path = DocPath.forModule((ModuleElement)this.element);
+                    path = DocPaths.forModule((ModuleElement)this.element);
                     break;
                 case PACKAGE:
-                    path = DocPath.forPackage((PackageElement)this.element);
+                    path = configuration.docPaths.forPackage((PackageElement)this.element);
                     break;
                 default:
                     throw new AssertionError("unknown kind:" + this.element.getKind());
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Wed Feb 07 11:28:23 2018 -0800
@@ -210,6 +210,12 @@
     public HtmlVersion htmlVersion = null;
 
     /**
+     * Flag to enable/disable use of module directories when generating docs for modules
+     * Default: on (module directories are enabled).
+     */
+    public boolean useModuleDirectories = true;
+
+    /**
      * Collected set of doclint options
      */
     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
@@ -245,6 +251,8 @@
 
     protected final Messages messages;
 
+    protected DocPaths docPaths;
+
     /**
      * Creates an object to hold the configuration for a doclet.
      *
@@ -357,6 +365,7 @@
                 }
             }
         }
+        docPaths = new DocPaths(utils, useModuleDirectories);
         setCreateOverview();
         setTopFile(docEnv);
         workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
@@ -406,15 +415,15 @@
             topFile = DocPaths.overviewSummary(frames);
         } else {
             if (showModules) {
-                topFile = DocPath.empty.resolve(DocPaths.moduleSummary(modules.first()));
+                topFile = DocPath.empty.resolve(docPaths.moduleSummary(modules.first()));
             } else if (packages.size() == 1 && packages.first().isUnnamed()) {
                 List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
                 if (!classes.isEmpty()) {
                     TypeElement te = getValidClass(classes);
-                    topFile = DocPath.forClass(utils, te);
+                    topFile = docPaths.forClass(te);
                 }
             } else if (!packages.isEmpty()) {
-                topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
+                topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
             }
         }
     }
@@ -837,6 +846,13 @@
                     }
                     return true;
                 }
+            },
+            new XOption(resources, "--no-module-directories") {
+                @Override
+                public boolean process(String option, List<String> args) {
+                    useModuleDirectories = false;
+                    return true;
+                }
             }
         };
         Set<Doclet.Option> oset = new TreeSet<>();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -155,6 +155,8 @@
 
     protected final Links links;
 
+    protected final DocPaths docPaths;
+
     /**
      * To check whether annotation heading is printed or not.
      */
@@ -202,6 +204,7 @@
         this.path = path;
         this.pathToRoot = path.parent().invert();
         this.filename = path.basename();
+        this.docPaths = configuration.docPaths;
 
         messages.notice("doclet.Generating_0",
             DocFile.createFileForOutput(configuration, path).getPath());
@@ -399,7 +402,7 @@
      */
     public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
         return links.createLink(pathToRoot.resolve(
-                DocPaths.moduleSummary(mdle)), label, "", target);
+                docPaths.moduleSummary(mdle)), label, "", target);
     }
 
     /**
@@ -896,7 +899,7 @@
      * @param name File name, to which path string is.
      */
     protected DocPath pathString(PackageElement packageElement, DocPath name) {
-        return pathToRoot.resolve(DocPath.forPackage(packageElement).resolve(name));
+        return pathToRoot.resolve(docPaths.forPackage(packageElement).resolve(name));
     }
 
     /**
@@ -968,7 +971,7 @@
     public Content getModuleLink(ModuleElement mdle, Content label) {
         boolean included = utils.isIncluded(mdle);
         return (included)
-                ? links.createLink(pathToRoot.resolve(DocPaths.moduleSummary(mdle)), label, "", "")
+                ? links.createLink(pathToRoot.resolve(docPaths.moduleSummary(mdle)), label, "", "")
                 : label;
     }
 
@@ -997,7 +1000,7 @@
         }
         DocPath href = pathToRoot
                 .resolve(DocPaths.SOURCE_OUTPUT)
-                .resolve(DocPath.forClass(utils, te));
+                .resolve(docPaths.forClass(te));
         Content linkContent = links.createLink(href
                 .fragment(SourceToHTMLConverter.getAnchorName(utils, typeElement)), label, "", "");
         htmltree.addContent(linkContent);
@@ -1086,7 +1089,7 @@
 
     public DocLink getCrossModuleLink(String mdleName) {
         return configuration.extern.getExternalLink(mdleName, pathToRoot,
-            DocPaths.moduleSummary(mdleName).getPath());
+            docPaths.moduleSummary(mdleName).getPath());
     }
 
     /**
@@ -1945,22 +1948,22 @@
         DocPath redirectPathFromRoot = new SimpleElementVisitor9<DocPath, Void>() {
             @Override
             public DocPath visitType(TypeElement e, Void p) {
-                return DocPath.forPackage(utils.containingPackage(e));
+                return docPaths.forPackage(utils.containingPackage(e));
             }
 
             @Override
             public DocPath visitPackage(PackageElement e, Void p) {
-                return DocPath.forPackage(e);
+                return docPaths.forPackage(e);
             }
 
             @Override
             public DocPath visitVariable(VariableElement e, Void p) {
-                return DocPath.forPackage(utils.containingPackage(e));
+                return docPaths.forPackage(utils.containingPackage(e));
             }
 
             @Override
             public DocPath visitExecutable(ExecutableElement e, Void p) {
-                return DocPath.forPackage(utils.containingPackage(e));
+                return docPaths.forPackage(utils.containingPackage(e));
             }
 
             @Override
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -35,8 +35,9 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
 
@@ -53,9 +54,12 @@
 public class LinkFactoryImpl extends LinkFactory {
 
     private final HtmlDocletWriter m_writer;
+    private final DocPaths docPaths;
 
     public LinkFactoryImpl(HtmlDocletWriter writer) {
+        super(writer.configuration.utils);
         m_writer = writer;
+        docPaths = writer.configuration.docPaths;
     }
 
     /**
@@ -72,7 +76,6 @@
     @Override
     protected Content getClassLink(LinkInfo linkInfo) {
         BaseConfiguration configuration = m_writer.configuration;
-        Utils utils = configuration.utils;
         LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
         boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
         TypeElement typeElement = classLinkInfo.typeElement;
@@ -84,14 +87,14 @@
                      utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
             title = getClassToolTip(typeElement, isTypeLink);
         }
-        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
+        Content label = classLinkInfo.getClassLinkLabel(configuration);
 
         Content link = new ContentBuilder();
         if (utils.isIncluded(typeElement)) {
             if (configuration.isGeneratedDoc(typeElement)) {
                 DocPath filename = getPath(classLinkInfo);
                 if (linkInfo.linkToSelf ||
-                                !(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
+                                !(docPaths.forName(typeElement)).equals(m_writer.filename)) {
                         link.addContent(m_writer.links.createLink(
                                 filename.fragment(classLinkInfo.where),
                                 label,
@@ -140,7 +143,6 @@
 
     @Override
     public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
-        Utils utils = ((LinkInfoImpl)linkInfo).utils;
         ContentBuilder links = new ContentBuilder();
         List<? extends AnnotationMirror> annotations;
         if (utils.isAnnotated(linkInfo.type)) {
@@ -191,22 +193,21 @@
      * @return the tool tip for the appropriate class.
      */
     private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) {
-        BaseConfiguration configuration = m_writer.configuration;
-        Utils utils = configuration.utils;
+        Resources resources = m_writer.configuration.getResources();
         if (isTypeLink) {
-            return configuration.getText("doclet.Href_Type_Param_Title",
+            return resources.getText("doclet.Href_Type_Param_Title",
                     utils.getSimpleName(typeElement));
         } else if (utils.isInterface(typeElement)){
-            return configuration.getText("doclet.Href_Interface_Title",
+            return resources.getText("doclet.Href_Interface_Title",
                 utils.getPackageName(utils.containingPackage(typeElement)));
         } else if (utils.isAnnotationType(typeElement)) {
-            return configuration.getText("doclet.Href_Annotation_Title",
+            return resources.getText("doclet.Href_Annotation_Title",
                 utils.getPackageName(utils.containingPackage(typeElement)));
         } else if (utils.isEnum(typeElement)) {
-            return configuration.getText("doclet.Href_Enum_Title",
+            return resources.getText("doclet.Href_Enum_Title",
                 utils.getPackageName(utils.containingPackage(typeElement)));
         } else {
-            return configuration.getText("doclet.Href_Class_Title",
+            return resources.getText("doclet.Href_Class_Title",
                 utils.getPackageName(utils.containingPackage(typeElement)));
         }
     }
@@ -223,8 +224,8 @@
         if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
             //Not really necessary to do this but we want to be consistent
             //with 1.4.2 output.
-            return DocPath.forName(linkInfo.utils, linkInfo.typeElement);
+            return docPaths.forName(linkInfo.typeElement);
         }
-        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.utils, linkInfo.typeElement));
+        return m_writer.pathToRoot.resolve(docPaths.forClass(linkInfo.typeElement));
     }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -76,7 +76,7 @@
      * @param moduleElement moduleElement under consideration.
      */
     public ModuleFrameWriter(HtmlConfiguration configuration, ModuleElement moduleElement) {
-        super(configuration, DocPaths.moduleTypeFrame(moduleElement));
+        super(configuration, configuration.docPaths.moduleTypeFrame(moduleElement));
         this.mdle = moduleElement;
         if (configuration.getSpecifiedPackageElements().isEmpty()) {
             documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
@@ -101,7 +101,7 @@
                 ? HtmlTree.MAIN()
                 : body;
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
-                mdlgen.links.createLink(DocPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame"));
+                mdlgen.links.createLink(configuration.docPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame"));
         htmlTree.addContent(heading);
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.indexContainer);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -114,9 +114,9 @@
     }
 
     private Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
-        DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle));
-        DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle));
-        DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle));
+        DocLink mdlLink = new DocLink(docPaths.moduleFrame(mdle));
+        DocLink mtFrameLink = new DocLink(docPaths.moduleTypeFrame(mdle));
+        DocLink cFrameLink = new DocLink(docPaths.moduleSummary(mdle));
         HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
         String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');";
         anchor.addAttr(HtmlAttr.TARGET, target);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -76,7 +76,7 @@
      * @param mdle the module being documented
      */
     public static void generate(HtmlConfiguration configuration, ModuleElement mdle) throws DocFileIOException {
-        DocPath filename = DocPaths.moduleFrame(mdle);
+        DocPath filename = configuration.docPaths.moduleFrame(mdle);
         ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename);
         modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -178,7 +178,7 @@
      * @param mdle        Module under consideration.
      */
     public ModuleWriterImpl(HtmlConfiguration configuration, ModuleElement mdle) {
-        super(configuration, DocPaths.moduleSummary(mdle));
+        super(configuration, configuration.docPaths.moduleSummary(mdle));
         this.mdle = mdle;
         this.moduleMode = configuration.docEnv.getModuleMode();
         computeModulesData();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,6 @@
 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
 /**
@@ -79,7 +78,8 @@
      * @param packageElement PackageElement under consideration.
      */
     public PackageFrameWriter(HtmlConfiguration configuration, PackageElement packageElement) {
-        super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
+        super(configuration,
+                configuration.docPaths.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
         this.packageElement = packageElement;
         if (configuration.getSpecifiedPackageElements().isEmpty()) {
             documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -82,7 +82,7 @@
     public static void generate(HtmlConfiguration configuration,
                                 PackageElement pkg, boolean noDeprecated)
             throws DocFileIOException {
-        DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
+        DocPath path = configuration.docPaths.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
         PackageTreeWriter packgen = new PackageTreeWriter(configuration, path, pkg);
         packgen.generatePackageTreeFile();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -75,7 +75,7 @@
     public PackageUseWriter(HtmlConfiguration configuration,
                             ClassUseMapper mapper, DocPath filename,
                             PackageElement pkgElement) {
-        super(configuration, DocPath.forPackage(pkgElement).resolve(filename));
+        super(configuration, configuration.docPaths.forPackage(pkgElement).resolve(filename));
         this.packageElement = pkgElement;
 
         // by examining all classes in this package, find what packages
@@ -221,7 +221,7 @@
                     .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
             for (TypeElement te : usingPackageToUsedClasses.get(packageName)) {
                 DocPath dp = pathString(te,
-                        DocPaths.CLASS_USE.resolve(DocPath.forName(utils, te)));
+                        DocPaths.CLASS_USE.resolve(docPaths.forName(te)));
                 Content stringContent = new StringContent(utils.getSimpleName(te));
                 Content typeContent = links.createLink(dp.fragment(getPackageAnchorName(usingPackage)),
                         stringContent);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -91,8 +91,8 @@
      * @param packageElement    PackageElement under consideration.
      */
     public PackageWriterImpl(HtmlConfiguration configuration, PackageElement packageElement) {
-        super(configuration, DocPath
-                .forPackage(packageElement)
+        super(configuration,
+                configuration.docPaths.forPackage(packageElement)
                 .resolve(DocPaths.PACKAGE_SUMMARY));
         this.packageElement = packageElement;
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, 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
@@ -182,7 +182,7 @@
             int lineno = 1;
             String line;
             relativePath = DocPaths.SOURCE_OUTPUT
-                    .resolve(DocPath.forPackage(utils, te))
+                    .resolve(configuration.docPaths.forPackage(te))
                     .invert();
             Content body = getHeader();
             Content pre = new HtmlTree(HtmlTag.PRE);
@@ -196,7 +196,7 @@
             addBlankLines(pre);
             Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
             body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div);
-            writeToFile(body, outputdir.resolve(DocPath.forClass(utils, te)));
+            writeToFile(body, outputdir.resolve(configuration.docPaths.forClass(te)));
         } catch (IOException e) {
             String message = resources.getText("doclet.exception.read.file", fo.getName());
             throw new SimpleDocletException(message, e);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Feb 07 11:28:23 2018 -0800
@@ -112,17 +112,18 @@
             SearchIndexItem si = new SearchIndexItem();
             si.setLabel(tagText);
             si.setDescription(desc);
+            DocPaths docPaths = configuration.docPaths;
             new SimpleElementVisitor9<Void, Void>() {
                 @Override
                 public Void visitModule(ModuleElement e, Void p) {
-                    si.setUrl(DocPaths.moduleSummary(e).getPath() + "#" + anchorName);
+                    si.setUrl(docPaths.moduleSummary(e).getPath() + "#" + anchorName);
                     si.setHolder(utils.getFullyQualifiedName(element));
                     return null;
                 }
 
                 @Override
                 public Void visitPackage(PackageElement e, Void p) {
-                    si.setUrl(DocPath.forPackage(e).getPath()
+                    si.setUrl(docPaths.forPackage(e).getPath()
                             + "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
                     si.setHolder(utils.getSimpleName(element));
                     return null;
@@ -130,7 +131,7 @@
 
                 @Override
                 public Void visitType(TypeElement e, Void p) {
-                    si.setUrl(DocPath.forClass(utils, e).getPath() + "#" + anchorName);
+                    si.setUrl(docPaths.forClass(e).getPath() + "#" + anchorName);
                     si.setHolder(utils.getFullyQualifiedName(e));
                     return null;
                 }
@@ -138,7 +139,7 @@
                 @Override
                 public Void visitVariable(VariableElement e, Void p) {
                     TypeElement te = utils.getEnclosingTypeElement(e);
-                    si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
+                    si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
                     si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
                     return null;
                 }
@@ -146,7 +147,7 @@
                 @Override
                 protected Void defaultAction(Element e, Void p) {
                     TypeElement te = utils.getEnclosingTypeElement(e);
-                    si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
+                    si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
                     si.setHolder(utils.getFullyQualifiedName(e));
                     return null;
                 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Feb 07 11:28:23 2018 -0800
@@ -335,6 +335,10 @@
 doclet.usage.nodeprecatedlist.description=\
     Do not generate deprecated list
 
+doclet.usage.no-module-directories.description=\
+    Do not group files for module documentation into \n\
+    module-specific directories
+
 doclet.usage.notree.description=\
     Do not generate class hierarchy
 
@@ -370,7 +374,7 @@
     Charset for cross-platform viewing of generated documentation
 
 doclet.usage.javafx.description=\
-    Enable javafx functionality
+    Enable JavaFX functionality
 
 doclet.usage.helpfile.parameters=\
     <file>
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -65,8 +65,7 @@
 /**
  * Configure the output based on the options. Doclets should sub-class
  * BaseConfiguration, to configure and add their own options. This class contains
- * all user options which are supported by the 1.1 doclet and the standard
- * doclet.
+ * all user options which are supported by the standard doclet.
  * <p>
  * <p><b>This is NOT part of any supported API.
  * If you write code that depends on this, you do so at your own risk.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, 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
@@ -46,7 +46,7 @@
 import javax.lang.model.util.Types;
 
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
 
 /**
@@ -192,7 +192,7 @@
     private final Types typeUtils;
     private final Utils utils;
 
-    public ClassUseMapper(HtmlConfiguration configuration, ClassTree classtree) {
+    public ClassUseMapper(BaseConfiguration configuration, ClassTree classtree) {
         docEnv = configuration.docEnv;
         elementUtils = docEnv.getElementUtils();
         typeUtils = docEnv.getTypeUtils();
@@ -414,11 +414,11 @@
         }
     }
 
-    private <T> List<T> refList(Map<TypeElement, List<T>> map, Element element) {
+    private <T> List<T> refList(Map<TypeElement, List<T>> map, TypeElement element) {
         List<T> list = map.get(element);
         if (list == null) {
             list = new ArrayList<>();
-            map.put((TypeElement) element, list);
+            map.put(element, list);
         }
         return list;
     }
@@ -570,7 +570,7 @@
             @Override
             public Void visitPackage(PackageElement e, Void p) {
                 for (AnnotationMirror a : e.getAnnotationMirrors()) {
-                    refList(map, a.getAnnotationType().asElement()).add(holder);
+                    refList(map, (TypeElement) a.getAnnotationType().asElement()).add(holder);
                 }
                 return null;
             }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java	Wed Feb 07 11:28:23 2018 -0800
@@ -61,94 +61,6 @@
         return (p == null) || p.isEmpty() ? empty : new DocPath(p);
     }
 
-    /**
-     * Returns the path for a class.
-     * For example, if the class is java.lang.Object,
-     * the path is java/lang/Object.html.
-     * @param utils utility class for handling type elements
-     * @param typeElement the type element
-     * @return the path
-     */
-    public static DocPath forClass(Utils utils, TypeElement typeElement) {
-        return (typeElement == null)
-                ? empty
-                : forPackage(utils.containingPackage(typeElement)).resolve(forName(utils, typeElement));
-    }
-
-    /**
-     * Returns the path for the simple name of a class.
-     * For example, if the class is java.lang.Object,
-     * the path is Object.html.
-     * @param utils utility class for handling type elements
-     * @param typeElement the type element
-     * @return the path
-     */
-    public static DocPath forName(Utils utils, TypeElement typeElement) {
-        return (typeElement == null) ? empty : new DocPath(utils.getSimpleName(typeElement) + ".html");
-    }
-
-    /**
-     * Returns the path for the name of a module.
-     * For example, if the module is java.base,
-     * the path is java.base.
-     * @param mdle the module element
-     * @return the path
-     */
-    public static DocPath forModule(ModuleElement mdle) {
-        return mdle == null || mdle.isUnnamed()
-                ? empty
-                : DocPath.create(mdle.getQualifiedName().toString());
-    }
-
-    /**
-     * Returns the path for the package of a class.
-     * For example, if the class is java.lang.Object,
-     * the path is java/lang.
-     * @param utils utility class for handling type elements
-     * @param typeElement the type element
-     * @return the path
-     */
-    public static DocPath forPackage(Utils utils, TypeElement typeElement) {
-        return (typeElement == null) ? empty : forPackage(utils.containingPackage(typeElement));
-    }
-
-    /**
-     * Returns the path for a package.
-     * For example, if the package is java.lang,
-     * the path is java/lang.
-     * @param pkgElement the package element
-     * @return the path
-     */
-    public static DocPath forPackage(PackageElement pkgElement) {
-        return pkgElement == null || pkgElement.isUnnamed()
-                ? empty
-                : DocPath.create(pkgElement.getQualifiedName().toString().replace('.', '/'));
-    }
-
-    /**
-     * Returns the inverse path for a package.
-     * For example, if the package is java.lang,
-     * the inverse path is ../...
-     * @param pkgElement the package element
-     * @return the path
-     */
-    public static DocPath forRoot(PackageElement pkgElement) {
-        String name = (pkgElement == null || pkgElement.isUnnamed())
-                ? ""
-                : pkgElement.getQualifiedName().toString();
-        return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
-    }
-
-    /**
-     * Returns the relative path from one package to another.
-     * @param from the initial package
-     * @param to the target package
-     * @return the path
-     */
-    public static DocPath relativePath(PackageElement from, PackageElement to) {
-        return forRoot(from).resolve(forPackage(to));
-    }
-
     protected DocPath(String p) {
         path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p);
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package jdk.javadoc.internal.doclets.toolkit.util;
 
 import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
 
 /**
  * Standard DocPath objects.
@@ -37,6 +39,16 @@
  *
  */
 public class DocPaths {
+    private final boolean useModuleDirectories;
+    private final String moduleSeparator;
+    private final Utils utils;
+
+    public DocPaths(Utils utils, boolean useModuleDirectories) {
+        this.utils = utils;
+        this.useModuleDirectories = useModuleDirectories;
+        moduleSeparator = useModuleDirectories ? "/module-" : "-";
+    }
+
     /** The name of the file for all classes, without using frames, when --no-frames is specified. */
     public static final DocPath ALLCLASSES = DocPath.create("allclasses.html");
 
@@ -80,7 +92,11 @@
     /** The name of the directory for the split index files. */
     public static final DocPath INDEX_FILES = DocPath.create("index-files");
 
-    /** Generate the name of one of the files in the split index. */
+    /**
+     * Generate the name of one of the files in the split index.
+     * @param n the position in the index
+     * @return the path
+     */
     public static DocPath indexN(int n) {
         return DocPath.create("index-" + n + ".html");
     }
@@ -173,29 +189,153 @@
     /** The name of the file for the package usage info. */
     public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
 
-    /** The name of the output directory for module documentation files. */
-    public static DocPath moduleDocFiles(ModuleElement mdle) {
-        return DocPath.create(mdle.getQualifiedName() + "-doc-files");
+    /**
+     * Returns the path for a type element.
+     * For example, if the type element is {@code java.lang.Object},
+     * the path is {@code java/lang/Object.html}.
+     *
+     * @param typeElement the type element
+     * @return the path
+     */
+    public DocPath forClass(TypeElement typeElement) {
+        return (typeElement == null)
+                ? DocPath.empty
+                : forPackage(utils.containingPackage(typeElement)).resolve(forName(typeElement));
     }
 
-    /** The name of the file for the module frame. */
-    public static DocPath moduleFrame(ModuleElement mdle) {
-        return DocPath.create(mdle.getQualifiedName() + "-frame.html");
+    /**
+     * Returns the path for the simple name of a type element.
+     * For example, if the type element is {@code java.lang.Object},
+     * the path is {@code Object.html}.
+     *
+     * @param typeElement the type element
+     * @return the path
+     */
+    public DocPath forName(TypeElement typeElement) {
+        return (typeElement == null)
+                ? DocPath.empty
+                : new DocPath(utils.getSimpleName(typeElement) + ".html");
     }
 
-    /** The name of the file for the module summary. */
-    public static DocPath moduleSummary(ModuleElement mdle) {
-        return DocPaths.moduleSummary(mdle.getQualifiedName().toString());
+    public static DocPath forModule(ModuleElement mdle) {
+        return mdle == null || mdle.isUnnamed()
+                ? DocPath.empty
+                : DocPath.create(mdle.getQualifiedName().toString());
     }
 
-    /** The name of the file for the module summary. */
-    public static DocPath moduleSummary(String mdleName) {
-        return DocPath.create(mdleName + "-summary.html");
+    /**
+     * Returns the path for the package of a type element.
+     * For example, if the type element is {@code java.lang.Object},
+     * the path is {@code java/lang}.
+     *
+     * @param typeElement the type element
+     * @return the path
+     */
+    public DocPath forPackage(TypeElement typeElement) {
+        return (typeElement == null)
+                ? DocPath.empty
+                : forPackage(utils.containingPackage(typeElement));
     }
 
-    /** The name of the file for the module frame. */
-    public static DocPath moduleTypeFrame(ModuleElement mdle) {
-        return DocPath.create(mdle.getQualifiedName() + "-type-frame.html");
+    /**
+     * Returns the path for a package.
+     * For example, if the package is {@code java.lang},
+     * the path is {@code java/lang}.
+     *
+     * @param pkgElement the package element
+     * @return the path
+     */
+    public DocPath forPackage(PackageElement pkgElement) {
+        if (pkgElement == null || pkgElement.isUnnamed()) {
+            return DocPath.empty;
+        }
+
+        DocPath pkgPath = DocPath.create(pkgElement.getQualifiedName().toString().replace('.', '/'));
+        if (useModuleDirectories) {
+            ModuleElement mdle = (ModuleElement) pkgElement.getEnclosingElement();
+            return forModule(mdle).resolve(pkgPath);
+        } else {
+            return pkgPath;
+        }
+    }
+
+    /**
+     * Returns the inverse path for a package.
+     * For example, if the package is {@code java.lang},
+     * the inverse path is {@code ../..}.
+     *
+     * @param pkgElement the package element
+     * @return the path
+     */
+    public static DocPath forRoot(PackageElement pkgElement) {
+        String name = (pkgElement == null || pkgElement.isUnnamed())
+                ? ""
+                : pkgElement.getQualifiedName().toString();
+        return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
+    }
+
+    /**
+     * Returns a relative path from one package to another.
+     *
+     * @param from the origin of the relative path
+     * @param to the destination of the relative path
+     * @return the path
+     */
+    public DocPath relativePath(PackageElement from, PackageElement to) {
+        return forRoot(from).resolve(forPackage(to));
+    }
+
+    /**
+     * The path for the output directory for module documentation files.
+     * @param mdle the module
+     * @return the path
+     */
+    public DocPath moduleDocFiles(ModuleElement mdle) {
+        return createModulePath(mdle, "doc-files");
+    }
+
+    /**
+     * The path for the file for a module's frame page.
+     * @param mdle the module
+     * @return the path
+     */
+    public DocPath moduleFrame(ModuleElement mdle) {
+        return createModulePath(mdle, "frame.html");
+    }
+
+    /**
+     * The path for the file for a module's summary page.
+     * @param mdle the module
+     * @return the path
+     */
+    public DocPath moduleSummary(ModuleElement mdle) {
+        return createModulePath(mdle, "summary.html");
+    }
+
+    /**
+     * The path for the file for a module's summary page.
+     * @param mdleName the module
+     * @return the path
+     */
+    public DocPath moduleSummary(String mdleName) {
+        return createModulePath(mdleName, "summary.html");
+    }
+
+    /**
+     * The path for the file for a module's type frame page.
+     * @param mdle the module
+     * @return the path
+     */
+    public DocPath moduleTypeFrame(ModuleElement mdle) {
+        return createModulePath(mdle, "type-frame.html");
+    }
+
+    private DocPath createModulePath(ModuleElement mdle, String path) {
+        return DocPath.create(mdle.getQualifiedName() + moduleSeparator + path);
+    }
+
+    private DocPath createModulePath(String moduleName, String path) {
+        return DocPath.create(moduleName + moduleSeparator + path);
     }
 
     /** The name of the file for the module overview frame. */
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -82,7 +82,6 @@
 import com.sun.source.util.SimpleDocTreeVisitor;
 import com.sun.source.util.TreePath;
 import com.sun.tools.javac.model.JavacTypes;
-import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.TypeParameterElement;
@@ -39,7 +38,6 @@
 import javax.lang.model.type.WildcardType;
 import javax.lang.model.util.SimpleTypeVisitor9;
 
-import jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
@@ -54,6 +52,11 @@
  * @author Jamie Ho
  */
 public abstract class LinkFactory {
+    protected final Utils utils;
+
+    protected LinkFactory(Utils utils) {
+        this.utils = utils;
+    }
 
     /**
      * Return an empty instance of a content object.
@@ -69,7 +72,6 @@
      * @return the output of the link.
      */
     public Content getLink(LinkInfo linkInfo) {
-        Utils utils = ((LinkInfoImpl) linkInfo).configuration.utils;
         if (linkInfo.type != null) {
             SimpleTypeVisitor9<Content, LinkInfo> linkVisitor =
                     new SimpleTypeVisitor9<Content, LinkInfo>() {
@@ -207,26 +209,27 @@
     }
 
     /**
-     * Return the link to the given class.
+     * Returns a link to the given class.
      *
-     * @param linkInfo the information about the link to construct.
+     * @param linkInfo the information about the link to construct
      *
      * @return the link for the given class.
      */
     protected abstract Content getClassLink(LinkInfo linkInfo);
 
     /**
-     * Return the link to the given type parameter.
+     * Returns a link to the given type parameter.
      *
-     * @param linkInfo     the information about the link to construct.
-     * @param typeParam the type parameter to link to.
+     * @param linkInfo     the information about the link to construct
+     * @param typeParam the type parameter to link to
+     * @return the link
      */
     protected abstract Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam);
 
     /**
-     * Return the links to the type parameters.
+     * Returns links to the type parameters.
      *
-     * @param linkInfo     the information about the link to construct.
+     * @param linkInfo     the information about the link to construct
      * @return the links to the type parameters.
      */
     public Content getTypeParameterLinks(LinkInfo linkInfo) {
@@ -234,15 +237,14 @@
     }
 
     /**
-     * Return the links to the type parameters.
+     * Returns links to the type parameters.
      *
-     * @param linkInfo     the information about the link to construct.
-     * @param isClassLabel true if this is a class label.  False if it is
-     *                     the type parameters portion of the link.
-     * @return the links to the type parameters.
+     * @param linkInfo     the information about the link to construct
+     * @param isClassLabel true if this is a class label, or false if it is
+     *                     the type parameters portion of the link
+     * @return the links to the type parameters
      */
     public Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
-        Utils utils = ((LinkInfoImpl)linkInfo).utils;
         Content links = newContent();
         List<TypeMirror> vars = new ArrayList<>();
         TypeMirror ctype = linkInfo.type != null
--- a/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java	Wed Feb 07 11:28:23 2018 -0800
@@ -49,26 +49,26 @@
                 "--module-source-path", testSrc("modules"),
                 "--module", "acme.mdle");
         checkExit(Exit.OK);
-        checkOrder("p/doc-files/inpackage.html",
+        checkOrder("acme.mdle/p/doc-files/inpackage.html",
                 "\"Hello World\" (phi-WINDOW-TITLE-phi)",
                 "phi-TOP-phi",
                 // check top navbar
-                "<a href=\"../../acme.mdle-summary.html\">Module</a>",
+                "<a href=\"../../module-summary.html\">Module</a>",
                 "<a href=\"../package-summary.html\">Package</a>",
-                "<a href=\"../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../index-all.html\">Index</a>",
+                "<a href=\"../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../index-all.html\">Index</a>",
                 "phi-HEADER-phi",
                 "In a named module acme.module and named package "
                         + "<a href=\"../package-summary.html\"><code>p</code></a>.",
                 "\"simpleTagLabel\">Since:</",
                 "1940",
                 // check bottom navbar
-                "<a href=\"../../acme.mdle-summary.html\">Module</a>",
+                "<a href=\"../../module-summary.html\">Module</a>",
                 "<a href=\"../package-summary.html\">Package</a>",
-                "<a href=\"../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../index-all.html\">Index</a>",
+                "<a href=\"../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../index-all.html\">Index</a>",
                 "phi-FOOTER-phi",
                 "phi-BOTTOM-phi"
         );
@@ -86,52 +86,53 @@
                 "--module-source-path", testSrc("modules"),
                 "--module", "acme.mdle,acme2.mdle");
         checkExit(Exit.OK);
-        checkOrder("p/doc-files/inpackage.html",
+        checkOrder("acme.mdle/p/doc-files/inpackage.html",
                 "\"Hello World\" (phi-WINDOW-TITLE-phi)",
                 "phi-TOP-phi",
                 // check top navbar
-                "<a href=\"../../acme.mdle-summary.html\">Module</a>",
+                "<a href=\"../../module-summary.html\">Module</a>",
                 "<a href=\"../package-summary.html\">Package</a>",
-                "<a href=\"../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../index-all.html\">Index</a>",
+                "<a href=\"../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../index-all.html\">Index</a>",
                 "phi-HEADER-phi",
                 "In a named module acme.module and named package "
                         + "<a href=\"../package-summary.html\"><code>p</code></a>.",
                 "\"simpleTagLabel\">Since:</",
                 "1940",
                 // check bottom navbar
-                "<a href=\"../../acme.mdle-summary.html\">Module</a>",
+                "<a href=\"../../module-summary.html\">Module</a>",
                 "<a href=\"../package-summary.html\">Package</a>",
-                "<a href=\"../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../index-all.html\">Index</a>",
+                "<a href=\"../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../index-all.html\">Index</a>",
                 "phi-FOOTER-phi",
                 "phi-BOTTOM-phi"
         );
 
         // check the bottom most doc file
-        checkOrder("p2/doc-files/sub-dir/sub-dir-1/SubSubReadme.html",
+        checkOrder("acme2.mdle/p2/doc-files/sub-dir/sub-dir-1/SubSubReadme.html",
                 "SubSubReadme (phi-WINDOW-TITLE-phi)",
                 "phi-TOP-phi",
                 // check top navbar
-                "<a href=\"../../../../acme2.mdle-summary.html\">Module</a>",
+                "<a href=\"../../../../module-summary.html\">Module</a>",
                 "<a href=\"../../../package-summary.html\">Package</a>",
-                "<a href=\"../../../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../../../index-all.html\">Index</a>",
+                "<a href=\"../../../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../../../index-all.html\">Index</a>",
                 "phi-HEADER-phi",
                 "SubSubReadme.html at third level of doc-file directory.",
                 // check bottom navbar
-                "<a href=\"../../../../acme2.mdle-summary.html\">Module</a>",
+                "<a href=\"../../../../module-summary.html\">Module</a>",
                 "<a href=\"../../../package-summary.html\">Package</a>",
-                "<a href=\"../../../../overview-tree.html\">Tree</a>",
-                "<a href=\"../../../../deprecated-list.html\">Deprecated</a>",
-                "<a href=\"../../../../index-all.html\">Index</a>",
+                "<a href=\"../../../../../overview-tree.html\">Tree</a>",
+                "<a href=\"../../../../../deprecated-list.html\">Deprecated</a>",
+                "<a href=\"../../../../../index-all.html\">Index</a>",
                 "phi-FOOTER-phi",
                 "phi-BOTTOM-phi"
         );
     }
+
     @Test
     void testDocFilesInModulePackagesWithRecursiveCopy() {
         javadoc("-d", "modules-out-recursive",
@@ -139,7 +140,7 @@
                 "--module-source-path", testSrc("modules"),
                 "--module", "acme.mdle");
         checkExit(Exit.OK);
-        checkOutput("p/doc-files/inpackage.html", true,
+        checkOutput("acme.mdle/p/doc-files/inpackage.html", true,
                 "In a named module acme.module and named package "
                 + "<a href=\"../package-summary.html\"><code>p</code></a>."
         );
@@ -153,7 +154,7 @@
                 "--module-source-path", testSrc("modules"),
                 "--module", "acme.mdle");
         checkExit(Exit.OK);
-        checkOutput("p/doc-files/inpackage.html", true,
+        checkOutput("acme.mdle/p/doc-files/inpackage.html", true,
                 "In a named module acme.module and named package "
                 + "<a href=\"../package-summary.html\"><code>p</code></a>."
         );
--- a/test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -301,18 +301,20 @@
         private void checkFrameFiles() {
             // these files are all only generated in frames mode
 
-            // <module>-frame.html and <module>-type-frame.html files
+            // <module>/module-frame.html and <module>/module-type-frame.html files
             checkFiles(frames, classes.stream()
                 .filter(c -> isInModule(c))
                 .map(c -> modulePart(c))
                 .flatMap(m -> Arrays.asList(
-                        m + "-frame.html",
-                        m + "-type-frame.html").stream())
+                        m + "/module-frame.html",
+                        m + "/module-type-frame.html").stream())
                 .collect(Collectors.toSet()));
 
             // <package>/package-frame.html files
             checkFiles(frames, classes.stream()
-                    .map(c -> packagePart(c) + "/package-frame.html")
+                    .map(c -> (isInModule(c) ? (modulePart(c) + "/") : "")
+                                + packagePart(c)
+                                + "/package-frame.html")
                     .collect(Collectors.toSet()));
         }
 
@@ -360,7 +362,8 @@
             // contain FRAMES/NO-FRAMES links in frames mode
             List<String> navbarFiles = new ArrayList<>();
             navbarFiles.addAll(classes.stream()
-                    .map(c -> toHtml(packageClassPart(c)))
+                    .map(c -> (isInModule(c) ? (modulePart(c) + "/") : "")
+                                + toHtml(packageClassPart(c)))
                     .collect(Collectors.toSet()));
             for (String f : navbarFiles) {
                 checkOutput(f, frames,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java	Wed Feb 07 11:28:23 2018 -0800
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017, 2018, 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 8195795
+ * @summary test the use of module directories in output,
+ *          and the --no-module-directories option
+ * @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 ../lib /tools/lib
+ * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester
+ * @run main TestModuleDirs
+ */
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.ModuleBuilder;
+import toolbox.ToolBox;
+
+public class TestModuleDirs extends JavadocTester {
+
+    public final ToolBox tb;
+    public static void main(String... args) throws Exception {
+        TestModuleDirs tester = new TestModuleDirs();
+        tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
+    }
+
+    public TestModuleDirs() {
+        tb = new ToolBox();
+    }
+
+    @Test
+    public void testNoModules(Path base) throws IOException {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src, "package p; public class C { }");
+
+        javadoc("-d", base.resolve("api").toString(),
+                "-sourcepath", src.toString(),
+                "-quiet",
+                "p");
+
+        checkExit(Exit.OK);
+        checkFiles(true, "p/package-summary.html");
+    }
+
+    @Test
+    public void testNoModuleDirs(Path base) throws IOException {
+        Path src = base.resolve("src");
+        new ModuleBuilder(tb, "m")
+                .classes("package p; public class A {}")
+                .exports("p")
+                .write(src);
+
+        javadoc("-d", base.resolve("api").toString(),
+                "-quiet",
+                "--module-source-path", src.toString(),
+                "--no-module-directories",
+                "--module", "m");
+
+        checkExit(Exit.OK);
+        checkFiles(true,
+                "m-summary.html",
+                "p/package-summary.html");
+        checkFiles(false,
+                "m/module-summary.html",
+                "m/p/package-summary.html");
+    }
+
+    @Test
+    public void testModuleDirs(Path base) throws IOException {
+        Path src = base.resolve("src");
+        new ModuleBuilder(tb, "m")
+                .classes("package p; public class A {}")
+                .exports("p")
+                .write(src);
+
+        javadoc("-d", base.resolve("api").toString(),
+                "-quiet",
+                "--module-source-path", src.toString(),
+                "--module", "m");
+
+        checkExit(Exit.OK);
+        checkFiles(false,
+                "m-summary.html",
+                "p/package-summary.html");
+        checkFiles(true,
+                "m/module-summary.html",
+                "m/p/package-summary.html");
+    }
+}
+
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -64,7 +64,7 @@
                 "--module", "empty");
         checkExit(Exit.OK);
 
-        checkOutput("empty-summary.html", true,
+        checkOutput("empty/module-summary.html", true,
                 "module empty.");
     }
 
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestIndirectExportsOpens.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestIndirectExportsOpens.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -156,15 +156,15 @@
         // In details mode all kinds of packages from java.base,
         // could be listed in the indirects section, so just
         // check for minimal expected strings.
-        checkOutput("a-summary.html", true,
+        checkOutput("a/module-summary.html", true,
                 "Indirect Exports table",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"m-summary.html\">m</a></th>\n"
-                + "<td class=\"colLast\"><a href=\"exportsto/package-summary.html\">exportsto</a></td>\n"
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"../m/module-summary.html\">m</a></th>\n"
+                + "<td class=\"colLast\"><a href=\"../m/exportsto/package-summary.html\">exportsto</a></td>\n"
                 + "</tr>\n");
 
-        checkOutput("a-summary.html", true,
+        checkOutput("a/module-summary.html", true,
                 "Indirect Opens table",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"m-summary.html\">m</a></th>\n"
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"../m/module-summary.html\">m</a></th>\n"
                 + "<td class=\"colLast\">opensto</td>\n"
                 + "</tr>\n");
     }
@@ -183,11 +183,11 @@
 
         // Avoid false positives, just check for primary string absence.
         if (!present) {
-            checkOutput("a-summary.html", false, typeString);
+            checkOutput("a/module-summary.html", false, typeString);
             return;
         }
 
-        checkOutput("a-summary.html", present,
+        checkOutput("a/module-summary.html", present,
                 "<table class=\"packagesSummary\" summary=\"" + typeString + " table, listing modules, and packages\">\n"
                 + "<caption><span>" + typeString + "</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
@@ -196,8 +196,8 @@
                 + "</tr>\n"
                 + "<tbody>\n"
                 + "<tr class=\"altColor\">\n"
-                + "<th class=\"colFirst\" scope=\"row\"><a href=\"m-summary.html\">m</a></th>\n"
-                + "<td class=\"colLast\"><a href=\"pm/package-summary.html\">pm</a></td>\n"
+                + "<th class=\"colFirst\" scope=\"row\"><a href=\"../m/module-summary.html\">m</a></th>\n"
+                + "<td class=\"colLast\"><a href=\"../m/pm/package-summary.html\">pm</a></td>\n"
                 + "</tr>\n"
                 + "</tbody>\n"
                 + "</table>\n");
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
                 "--module", "m");
 
         checkExit(Exit.OK);
-        checkOutput("m-summary.html", false,
+        checkOutput("m/module-summary.html", false,
                 "<h3>Packages</h3>\n"
                 + "<table class=\"packagesSummary\" summary=\"Packages table, "
                 + "listing packages, and an explanation\">");
@@ -159,7 +159,7 @@
         checkTableHead("m", ColKind.EXPORTED_TO);
         checkPackageRow("m", "p", "i0", "All Modules", null, "&nbsp;");
         checkPackageRow("m", "q", "i1",
-                "<a href=\"other-summary.html\">other</a>", null, "&nbsp;");
+                "<a href=\"../other/module-summary.html\">other</a>", null, "&nbsp;");
     }
 
     @Test
@@ -247,11 +247,11 @@
         checkPackageRow("m", "c", "i0", "None", "None", "&nbsp;");
         checkPackageRow("m", "e.all", "i1", "All Modules", "None", "&nbsp;");
         checkPackageRow("m", "e.other", "i2",
-                "<a href=\"other-summary.html\">other</a>", "None", "&nbsp;");
+                "<a href=\"../other/module-summary.html\">other</a>", "None", "&nbsp;");
         checkPackageRow("m", "eo", "i3", "All Modules", "All Modules", "&nbsp;");
         checkPackageRow("m", "o.all", "i4", "None", "All Modules", "&nbsp;");
         checkPackageRow("m", "o.other", "i5", "None",
-                "<a href=\"other-summary.html\">other</a>", "&nbsp;");
+                "<a href=\"../other/module-summary.html\">other</a>", "&nbsp;");
     }
 
     @Test
@@ -367,7 +367,7 @@
         checkTableHead("m", ColKind.OPENED_TO);
         checkPackageRow("m", "p", "i0", null, "All Modules", "&nbsp;");
         checkPackageRow("m", "q", "i1", null,
-                "<a href=\"other-summary.html\">other</a>", "&nbsp;");
+                "<a href=\"../other/module-summary.html\">other</a>", "&nbsp;");
     }
 
     @Test
@@ -443,7 +443,7 @@
                         + "</caption>";
         }
 
-        checkOutput(moduleName + "-summary.html", true, expect);
+        checkOutput(moduleName + "/module-summary.html", true, expect);
     }
 
 
@@ -461,7 +461,7 @@
         sb.append("<th class=\"colLast\" scope=\"col\">Description</th>\n"
             + "</tr>");
 
-        checkOutput(moduleName + "-summary.html", true, sb.toString());
+        checkOutput(moduleName + "/module-summary.html", true, sb.toString());
     }
 
     private void checkPackageRow(String moduleName, String packageName,
@@ -481,7 +481,7 @@
         }
         sb.append("<td class=\"colLast\">" + desc + "</td>");
 
-        checkOutput(moduleName + "-summary.html", true, sb.toString());
+        checkOutput(moduleName + "/module-summary.html", true, sb.toString());
     }
 
 }
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -124,31 +124,31 @@
                 "moduleServiceUserNoDescription/pkgServiceUserNoDescription");
         checkExit(Exit.OK);
 
-        checkOutput("moduleServiceProvider-summary.html", true,
+        checkOutput("moduleServiceProvider/module-summary.html", true,
                 "<tr class=\"altColor\">\n"
-                + "<th class=\"colFirst\" scope=\"row\"><a href=\"pkgService/Service.html\" "
+                + "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleService/pkgService/Service.html\" "
                 + "title=\"interface in pkgService\">Service</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">Provides a service whose name is ServiceProvider.</div>\n"
                 + "</td>\n"
                 + "</tr>");
-        checkOutput("moduleServiceUser-summary.html", true,
+        checkOutput("moduleServiceUser/module-summary.html", true,
                 "<tr class=\"altColor\">\n"
-                + "<th class=\"colFirst\" scope=\"row\"><a href=\"pkgService/Service.html\" title=\"interface in pkgService\">Service</a></th>\n"
+                + "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleService/pkgService/Service.html\" title=\"interface in pkgService\">Service</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">If no other provider is found, a default internal implementation will be used.</div>\n"
                 + "</td>\n"
                 + "</tr>");
-        checkOutput("moduleServiceUserNoDescription-summary.html", true,
+        checkOutput("moduleServiceUserNoDescription/module-summary.html", true,
                 "<tr class=\"altColor\">\n"
-                + "<th class=\"colFirst\" scope=\"row\"><a href=\"pkgService/Service.html\" title=\"interface in pkgService\">Service</a></th>\n"
+                + "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleService/pkgService/Service.html\" title=\"interface in pkgService\">Service</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">A service Interface for service providers.</div>\n"
                 + "</td>\n"
                 + "</tr>");
-        checkOutput("moduleServiceProvider-summary.html", false,
+        checkOutput("moduleServiceProvider/module-summary.html", false,
                 "A service Interface for service providers.");
-        checkOutput("moduleServiceUser-summary.html", false,
+        checkOutput("moduleServiceUser/module-summary.html", false,
                 "A service Interface for service providers.");
     }
 
@@ -169,7 +169,7 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", false,
+        checkOutput("m/module-summary.html", false,
                 "<h3>Services</h3>");
     }
 
@@ -190,10 +190,10 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<h3>Services</h3>");
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
                 "<caption><span>Uses</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
                 "<tr>\n" +
@@ -230,10 +230,10 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<h3>Services</h3>");
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
                 "<caption><span>Uses</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
                 "<tr>\n" +
@@ -270,7 +270,7 @@
 
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", false,
+        checkOutput("m/module-summary.html", false,
                 "<h3>Services</h3>");
     }
 
@@ -296,10 +296,10 @@
 
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<h3>Services</h3>");
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
                 "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
                 "<tr>\n" +
@@ -339,10 +339,10 @@
 
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<h3>Services</h3>");
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
                 "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
                 "<tr>\n" +
@@ -381,10 +381,10 @@
 
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<h3>Services</h3>");
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
                 "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
                 "<tr>\n" +
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java	Wed Feb 07 11:28:23 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -68,7 +68,7 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<a href=\"#module.description\">Description</a>&nbsp;|"
                 + "&nbsp;Modules&nbsp;|"
                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
@@ -92,7 +92,7 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "<a href=\"#module.description\">Description</a>&nbsp;|"
                 + "&nbsp;Modules&nbsp;|"
                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
@@ -114,7 +114,7 @@
                 "--module", "m");
         checkExit(Exit.OK);
 
-        checkOutput("m-summary.html", true,
+        checkOutput("m/module-summary.html", true,
                 "Description&nbsp;|&nbsp;Modules&nbsp;|"
                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
                 + "&nbsp;Services");
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Wed Feb 07 11:28:23 2018 -0800
@@ -444,14 +444,14 @@
     }
 
     void checkDescription(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a name=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a name=\"module.description\">\n"
                 + "<!--   -->\n"
@@ -478,14 +478,14 @@
     }
 
     void checkNoDescription(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
                 + "<!-- ============ PACKAGES SUMMARY =========== -->");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
@@ -495,7 +495,7 @@
     }
 
     void checkHtml5Description(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<section role=\"region\">\n"
                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal:"
                 + " This API element is subject to removal in a future version.</span>\n"
@@ -507,7 +507,7 @@
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<section role=\"region\">\n"
                 + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a id=\"module.description\">\n"
@@ -539,14 +539,14 @@
     }
 
     void checkHtml5NoDescription(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
                 + "<!-- ============ PACKAGES SUMMARY =========== -->");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
@@ -558,18 +558,18 @@
     void checkModuleLink() {
         checkOutput("overview-summary.html", true,
                 "<li>Module</li>");
-        checkOutput("moduleA-summary.html", true,
+        checkOutput("moduleA/module-summary.html", true,
                 "<li class=\"navBarCell1Rev\">Module</li>");
-        checkOutput("moduleB-summary.html", true,
+        checkOutput("moduleB/module-summary.html", true,
                 "<li class=\"navBarCell1Rev\">Module</li>");
-        checkOutput("testpkgmdlA/class-use/TestClassInModuleA.html", true,
-                "<li><a href=\"../../moduleA-summary.html\">Module</a></li>");
-        checkOutput("testpkgmdlB/package-summary.html", true,
-                "<li><a href=\"../moduleB-summary.html\">Module</a></li>");
-        checkOutput("testpkgmdlB/TestClassInModuleB.html", true,
-                "<li><a href=\"../moduleB-summary.html\">Module</a></li>");
-        checkOutput("testpkgmdlB/class-use/TestClassInModuleB.html", true,
-                "<li><a href=\"../../moduleB-summary.html\">Module</a></li>");
+        checkOutput("moduleA/testpkgmdlA/class-use/TestClassInModuleA.html", true,
+                "<li><a href=\"../../module-summary.html\">Module</a></li>");
+        checkOutput("moduleB/testpkgmdlB/package-summary.html", true,
+                "<li><a href=\"../module-summary.html\">Module</a></li>");
+        checkOutput("moduleB/testpkgmdlB/TestClassInModuleB.html", true,
+                "<li><a href=\"../module-summary.html\">Module</a></li>");
+        checkOutput("moduleB/testpkgmdlB/class-use/TestClassInModuleB.html", true,
+                "<li><a href=\"../../module-summary.html\">Module</a></li>");
     }
 
     void checkNoModuleLink() {
@@ -585,7 +585,7 @@
     }
 
     void checkModuleTags() {
-        checkOutput("moduletags-summary.html", true,
+        checkOutput("moduletags/module-summary.html", true,
                 "Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in "
                 + "testpkgmdltags\"><code>TestClassInModuleTags</code></a>.",
                 "Member Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html#"
@@ -605,7 +605,7 @@
                 + "<dd>1.0</dd>",
                 "<dt><span class=\"simpleTagLabel\">Author:</span></dt>\n"
                 + "<dd>Bhavesh Patel</dd>");
-        checkOutput("testpkgmdltags/TestClassInModuleTags.html", false,
+        checkOutput("moduletags/testpkgmdltags/TestClassInModuleTags.html", false,
                 "<dt><span class=\"simpleTagLabel\">Module Tag:</span></dt>\n"
                 + "<dd>Just a simple module tag.</dd>");
     }
@@ -716,7 +716,7 @@
     }
 
     void checkModuleSummary() {
-        checkOutput("moduleA-summary.html", true,
+        checkOutput("moduleA/module-summary.html", true,
                 "<ul class=\"subNavList\">\n"
                 + "<li>Module:&nbsp;</li>\n"
                 + "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a "
@@ -737,12 +737,12 @@
                 + "</a>",
                 "<tr class=\"altColor\">\n"
                 + "<td class=\"colFirst\">transitive</td>\n"
-                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleB/module-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>");
-        checkOutput("moduleB-summary.html", true,
+        checkOutput("moduleB/module-summary.html", true,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;Modules&nbsp;|&nbsp;"
                 + "<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">"
                 + "Services</a></li>",
@@ -785,7 +785,7 @@
     }
 
     void checkAggregatorModuleSummary() {
-        checkOutput("moduleT-summary.html", true,
+        checkOutput("moduleT/module-summary.html", true,
                 "<div class=\"header\">\n"
                 + "<h1 title=\"Module\" class=\"title\">Module&nbsp;moduleT</h1>\n"
                 + "</div>",
@@ -795,7 +795,7 @@
                 "<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"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleA/module-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
@@ -803,7 +803,7 @@
                 + "</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"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleB/module-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"
@@ -812,7 +812,7 @@
     }
 
     void checkNegatedModuleSummary() {
-        checkOutput("moduleA-summary.html", false,
+        checkOutput("moduleA/module-summary.html", false,
                 "<!-- ============ SERVICES SUMMARY =========== -->\n"
                 + "<a name=\"services.summary\">\n"
                 + "<!--   -->\n"
@@ -821,11 +821,11 @@
 
     void checkModuleClickThroughLinks() {
         checkOutput("module-overview-frame.html", true,
-                "<li><a href=\"moduleA-frame.html\" target=\"packageListFrame\" "
-                + "onclick=\"updateModuleFrame('moduleA-type-frame.html','moduleA-summary.html');"
+                "<li><a href=\"moduleA/module-frame.html\" target=\"packageListFrame\" "
+                + "onclick=\"updateModuleFrame('moduleA/module-type-frame.html','moduleA/module-summary.html');"
                 + "\">moduleA</a></li>",
-                "<li><a href=\"moduleB-frame.html\" target=\"packageListFrame\" "
-                + "onclick=\"updateModuleFrame('moduleB-type-frame.html','moduleB-summary.html');"
+                "<li><a href=\"moduleB/module-frame.html\" target=\"packageListFrame\" "
+                + "onclick=\"updateModuleFrame('moduleB/module-type-frame.html','moduleB/module-summary.html');"
                 + "\">moduleB</a></li>");
         checkOutput("script.js", true,
                 "function updateModuleFrame(pFrame, cFrame)\n"
@@ -837,37 +837,37 @@
 
     void checkModuleClickThrough(boolean found) {
         checkFiles(found,
-                "moduleA-type-frame.html",
-                "moduleB-type-frame.html");
+                "moduleA/module-type-frame.html",
+                "moduleB/module-type-frame.html");
     }
 
     void checkModuleFilesAndLinks(boolean found) {
-        checkFileAndOutput("testpkgmdlA/package-summary.html", found,
-                "<li><a href=\"../moduleA-summary.html\">Module</a></li>",
+        checkFileAndOutput("moduleA/testpkgmdlA/package-summary.html", found,
+                "<li><a href=\"../module-summary.html\">Module</a></li>",
                 "<div class=\"subTitle\"><span class=\"moduleLabelInPackage\">Module</span>&nbsp;"
-                + "<a href=\"../moduleA-summary.html\">moduleA</a></div>");
-        checkFileAndOutput("testpkgmdlA/TestClassInModuleA.html", found,
-                "<li><a href=\"../moduleA-summary.html\">Module</a></li>",
+                + "<a href=\"../module-summary.html\">moduleA</a></div>");
+        checkFileAndOutput("moduleA/testpkgmdlA/TestClassInModuleA.html", found,
+                "<li><a href=\"../module-summary.html\">Module</a></li>",
                 "<div class=\"subTitle\"><span class=\"moduleLabelInType\">Module</span>&nbsp;"
-                + "<a href=\"../moduleA-summary.html\">moduleA</a></div>");
-        checkFileAndOutput("testpkgmdlB/AnnotationType.html", found,
+                + "<a href=\"../module-summary.html\">moduleA</a></div>");
+        checkFileAndOutput("moduleB/testpkgmdlB/AnnotationType.html", found,
                 "<div class=\"subTitle\"><span class=\"moduleLabelInType\">Module</span>&nbsp;"
-                + "<a href=\"../moduleB-summary.html\">moduleB</a></div>",
+                + "<a href=\"../module-summary.html\">moduleB</a></div>",
                 "<div class=\"subTitle\"><span class=\"packageLabelInType\">"
                 + "Package</span>&nbsp;<a href=\"package-summary.html\">testpkgmdlB</a></div>");
         checkFiles(found,
-                "moduleA-frame.html",
-                "moduleA-summary.html",
+                "moduleA/module-frame.html",
+                "moduleA/module-summary.html",
                 "module-overview-frame.html");
     }
 
     void checkModuleFrameFiles(boolean found) {
         checkFiles(found,
-                "moduleC-frame.html",
-                "moduleC-type-frame.html",
+                "moduleC/module-frame.html",
+                "moduleC/module-type-frame.html",
                 "module-overview-frame.html");
         checkFiles(true,
-                "moduleC-summary.html",
+                "moduleC/module-summary.html",
                 "allclasses-frame.html",
                 "allclasses-noframe.html");
     }
@@ -880,74 +880,74 @@
     void checkModulesInSearch(boolean found) {
         checkOutput("index-all.html", found,
                 "<dl>\n"
-                + "<dt><a href=\"moduleA-summary.html\">moduleA</a> - module moduleA</dt>\n"
+                + "<dt><a href=\"moduleA/module-summary.html\">moduleA</a> - module moduleA</dt>\n"
                 + "<dd>\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
                 + "</dd>\n"
-                + "<dt><a href=\"moduleB-summary.html\">moduleB</a> - module moduleB</dt>\n"
+                + "<dt><a href=\"moduleB/module-summary.html\">moduleB</a> - module moduleB</dt>\n"
                 + "<dd>\n"
                 + "<div class=\"block\">This is a test description for the moduleB module.</div>\n"
                 + "</dd>\n"
                 + "</dl>",
                 "<dl>\n"
-                + "<dt><span class=\"searchTagLink\"><a href=\"moduleA-summary.html#searchphrase\">"
+                + "<dt><span class=\"searchTagLink\"><a href=\"moduleA/module-summary.html#searchphrase\">"
                 + "search phrase</a></span> - Search tag in moduleA</dt>\n"
                 + "<dd>with description</dd>\n"
-                + "<dt><span class=\"searchTagLink\"><a href=\"moduleB-summary.html#search_word\">"
+                + "<dt><span class=\"searchTagLink\"><a href=\"moduleB/module-summary.html#search_word\">"
                 + "search_word</a></span> - Search tag in moduleB</dt>\n"
                 + "<dd>&nbsp;</dd>\n"
                 + "</dl>");
         checkOutput("index-all.html", false,
-                "<dt><span class=\"searchTagLink\"><a href=\"moduleA-summary.html#searchphrase\">"
+                "<dt><span class=\"searchTagLink\"><a href=\"moduleA/module-summary.html#searchphrase\">"
                 + "search phrase</a></span> - Search tag in moduleA</dt>\n"
                 + "<dd>with description</dd>\n"
-                + "<dt><span class=\"searchTagLink\"><a href=\"moduleA-summary.html#searchphrase\">"
+                + "<dt><span class=\"searchTagLink\"><a href=\"moduleA/module-summary.html#searchphrase\">"
                 + "search phrase</a></span> - Search tag in moduleA</dt>\n"
                 + "<dd>with description</dd>");
     }
 
     void checkModuleModeCommon() {
         checkOutput("overview-summary.html", true,
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleA/module-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
                 + "</td>",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB/module-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>",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduletags-summary.html\">moduletags</a></th>\n"
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduletags/module-summary.html\">moduletags</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduletags module.<br>\n"
-                + " Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in testpkgmdltags\"><code>TestClassInModuleTags</code></a>.<br>\n"
-                + " Member Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html#testMethod-java.lang.String-\"><code>testMethod(String)</code></a>.<br>\n"
-                + " Package Link: <a href=\"testpkgmdltags/package-summary.html\"><code>testpkgmdltags</code></a>.<br></div>\n"
+                + " Type Link: <a href=\"moduletags/testpkgmdltags/TestClassInModuleTags.html\" title=\"class in testpkgmdltags\"><code>TestClassInModuleTags</code></a>.<br>\n"
+                + " Member Link: <a href=\"moduletags/testpkgmdltags/TestClassInModuleTags.html#testMethod-java.lang.String-\"><code>testMethod(String)</code></a>.<br>\n"
+                + " Package Link: <a href=\"moduletags/testpkgmdltags/package-summary.html\"><code>testpkgmdltags</code></a>.<br></div>\n"
                 + "</td>");
-        checkOutput("moduleA-summary.html", true,
+        checkOutput("moduleA/module-summary.html", true,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
                 + "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
-                + "<td class=\"colLast\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></td>\n");
-        checkOutput("moduleB-summary.html", true,
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleB/module-summary.html\">moduleB</a></th>\n"
+                + "<td class=\"colLast\"><a href=\"../moduleB/testpkgmdlB/package-summary.html\">testpkgmdlB</a></td>\n");
+        checkOutput("moduleB/module-summary.html", true,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/TestClassInModuleB.html\" title=\"class in testpkgmdlB\">TestClassInModuleB</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">With a test description for uses.</div>\n</td>\n");
-        checkOutput("moduletags-summary.html", true,
+        checkOutput("moduletags/module-summary.html", true,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">Modules"
                 + "</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
                 "<table class=\"requiresSummary\" summary=\"Indirect Requires table, listing modules, and an explanation\">\n"
                 + "<caption><span>Indirect Requires</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<td class=\"colFirst\">transitive</td>\n"
-                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleB/module-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>",
                 "<table class=\"packagesSummary\" summary=\"Indirect Exports table, listing modules, and packages\">\n"
                 + "<caption><span>Indirect Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<td class=\"colFirst\">transitive static</td>\n"
-                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleA/module-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
@@ -970,15 +970,15 @@
                 + "<th class=\"colFirst\" scope=\"col\">From</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Packages</th>\n"
                 + "</tr>\n",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
-                + "<td class=\"colLast\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></td>\n");
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleB/module-summary.html\">moduleB</a></th>\n"
+                + "<td class=\"colLast\"><a href=\"../moduleB/testpkgmdlB/package-summary.html\">testpkgmdlB</a></td>\n");
     }
 
     void checkModuleModeApi(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlA/package-summary.html\">testpkgmdlA</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;Modules&nbsp;|&nbsp;"
                 + "<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">Services</a></li>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
@@ -996,23 +996,23 @@
                 + "</tr>\n"
                 + "</tbody>\n"
                 + "</table>");
-        checkOutput("moduletags-summary.html", true,
+        checkOutput("moduletags/module-summary.html", true,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdltags/package-summary.html\">testpkgmdltags</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
     }
 
     void checkModuleModeAll(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<td class=\"colFirst\"> </td>\n"
                 + "<th class=\"colSecond\" scope=\"row\">java.base</th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>",
                 "<td class=\"colFirst\"> </td>\n"
-                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleC-summary.html\">moduleC</a></th>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><a href=\"../moduleC/module-summary.html\">moduleC</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleC module.</div>\n"
                 + "</td>",
-                "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleC-summary.html\">moduleC</a></th>\n"
-                + "<td class=\"colLast\"><a href=\"testpkgmdlC/package-summary.html\">testpkgmdlC</a></td>",
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"../moduleC/module-summary.html\">moduleC</a></th>\n"
+                + "<td class=\"colLast\"><a href=\"../moduleC/testpkgmdlC/package-summary.html\">testpkgmdlC</a></td>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlA/package-summary.html\">testpkgmdlA</a></th>\n"
                 + "<td class=\"colSecond\">All Modules</td>\n"
                 + "<td class=\"colLast\">&nbsp;</td>",
@@ -1023,7 +1023,7 @@
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"concealedpkgmdlA/package-summary.html\">concealedpkgmdlA</a></th>\n"
                 + "<td class=\"colSecond\">None</td>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
-        checkOutput("moduleB-summary.html", found,
+        checkOutput("moduleB/module-summary.html", found,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
                 + "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;<a href=\"#services.summary\">Services</a></li>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
@@ -1044,20 +1044,20 @@
                 "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Packages</span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\"><span>"
                 + "<a href=\"javascript:showPkgs(1);\">Exports</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span>"
                 + "<a href=\"javascript:showPkgs(2);\">Opens</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>");
-        checkOutput("moduleC-summary.html", found,
+        checkOutput("moduleC/module-summary.html", found,
                 "<caption><span>Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
                 + "<th class=\"colSecond\" scope=\"col\">Exported To Modules</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
                 + "</tr>");
-        checkOutput("moduletags-summary.html", true,
+        checkOutput("moduletags/module-summary.html", true,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdltags/package-summary.html\">testpkgmdltags</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
     }
 
     void checkModuleDeprecation(boolean found) {
-        checkOutput("moduleA-summary.html", found,
+        checkOutput("moduleA/module-summary.html", found,
                 "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal:"
                 + " This API element is subject to removal in a future version.</span>\n"
                 + "<div class=\"deprecationComment\">This module is deprecated.</div>\n"
@@ -1068,26 +1068,26 @@
                 + "<li><a href=\"#module\">Modules</a></li>\n"
                 + "</ul>",
                 "<tr class=\"altColor\">\n"
-                + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
+                + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"moduleA/module-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"deprecationComment\">This module is deprecated.</div>\n"
                 + "</td>\n"
                 + "</tr>");
-        checkOutput("moduleB-summary.html", !found,
+        checkOutput("moduleB/module-summary.html", !found,
                 "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span>\n"
                 + "<div class=\"deprecationComment\">This module is deprecated using just the javadoc tag.</div>\n");
-        checkOutput("moduletags-summary.html", found,
+        checkOutput("moduletags/module-summary.html", found,
                 "<p>@Deprecated\n"
                 + "</p>",
                 "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span></div>");
     }
 
     void checkModuleAnnotation() {
-        checkOutput("moduleB-summary.html", true,
+        checkOutput("moduleB/module-summary.html", true,
                 "<p><a href=\"testpkgmdlB/AnnotationType.html\" title=\"annotation in testpkgmdlB\">@AnnotationType</a>(<a href=\"testpkgmdlB/AnnotationType.html#optional--\">optional</a>=\"Module Annotation\",\n"
                 + "                <a href=\"testpkgmdlB/AnnotationType.html#required--\">required</a>=2016)\n"
                 + "</p>");
-        checkOutput("moduleB-summary.html", false,
+        checkOutput("moduleB/module-summary.html", false,
                 "@AnnotationTypeUndocumented");
     }
 
@@ -1099,7 +1099,7 @@
     }
 
     void checkModuleSummaryNoExported(boolean found) {
-        checkOutput("moduleNoExport-summary.html", found,
+        checkOutput("moduleNoExport/module-summary.html", found,
                 "<!-- ============ PACKAGES SUMMARY =========== -->\n"
                 + "<a name=\"packages.summary\">\n"
                 + "<!--   -->\n"
@@ -1194,30 +1194,30 @@
     }
 
     void checkModuleName(boolean found) {
-        checkOutput("test.moduleFullName-summary.html", found,
+        checkOutput("test.moduleFullName/module-summary.html", found,
                 "<div class=\"header\">\n"
                 + "<h1 title=\"Module\" class=\"title\">Module&nbsp;test.moduleFullName</h1>\n"
                 + "</div>");
         checkOutput("index-all.html", found,
                 "<h2 class=\"title\">T</h2>\n"
                 + "<dl>\n"
-                + "<dt><a href=\"test.moduleFullName-summary.html\">test.moduleFullName</a> - module test.moduleFullName</dt>\n"
+                + "<dt><a href=\"test.moduleFullName/module-summary.html\">test.moduleFullName</a> - module test.moduleFullName</dt>\n"
                 + "<dd>\n"
                 + "<div class=\"block\">This is a test description for the test.moduleFullName.</div>\n"
                 + "</dd>");
         checkOutput("module-overview-frame.html", found,
                 "<h2 title=\"Modules\">Modules</h2>\n"
                 + "<ul title=\"Modules\">\n"
-                + "<li><a href=\"moduleB-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('moduleB-type-frame.html','moduleB-summary.html');\">moduleB</a></li>\n"
-                + "<li><a href=\"test.moduleFullName-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('test.moduleFullName-type-frame.html','test.moduleFullName-summary.html');\">test.moduleFullName</a></li>\n"
+                + "<li><a href=\"moduleB/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('moduleB/module-type-frame.html','moduleB/module-summary.html');\">moduleB</a></li>\n"
+                + "<li><a href=\"test.moduleFullName/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('test.moduleFullName/module-type-frame.html','test.moduleFullName/module-summary.html');\">test.moduleFullName</a></li>\n"
                 + "</ul>");
-        checkOutput("test.moduleFullName-summary.html", !found,
+        checkOutput("test.moduleFullName/module-summary.html", !found,
                 "<div class=\"header\">\n"
                 + "<h1 title=\"Module\" class=\"title\">Module&nbsp;moduleFullName</h1>\n"
                 + "</div>");
         checkOutput("index-all.html", !found,
                 "<dl>\n"
-                + "<dt><a href=\"test.moduleFullName-summary.html\">moduleFullName</a> - module moduleFullName</dt>\n"
+                + "<dt><a href=\"test.moduleFullName/module-summary.html\">moduleFullName</a> - module moduleFullName</dt>\n"
                 + "<dd>\n"
                 + "<div class=\"block\">This is a test description for the test.moduleFullName.</div>\n"
                 + "</dd>\n"
@@ -1225,14 +1225,14 @@
     }
 
     void checkLinkOffline() {
-        checkOutput("testpkg3mdlB/package-summary.html", true,
+        checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
                 "<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/String.html?is-external=true\" "
                 + "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>");
-        checkOutput("testpkg3mdlB/package-summary.html", true,
+        checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
                 "<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/package-summary.html?is-external=true\" "
                 + "class=\"externalLink\"><code>Link to java.lang package</code></a>");
-        checkOutput("testpkg3mdlB/package-summary.html", true,
-                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base-summary.html?is-external=true\" "
+        checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
+                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/module-summary.html?is-external=true\" "
                 + "class=\"externalLink\"><code>Link to java.base module</code></a>");
 }
 }
--- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java	Wed Feb 07 09:48:43 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java	Wed Feb 07 11:28:23 2018 -0800
@@ -82,23 +82,23 @@
                 "Prev",
                 "Next");
 
-        checkOutput("m-summary.html", false,
+        checkOutput("m/module-summary.html", false,
                 "Prev&nbsp;Module",
                 "Next&nbsp;Module");
 
-        checkOutput("m2p1/package-summary.html", false,
+        checkOutput("m2/m2p1/package-summary.html", false,
                 "Prev&nbsp;Package",
                 "Next&nbsp;Package");
 
-        checkOutput("m2p1/Am2.html", false,
+        checkOutput("m2/m2p1/Am2.html", false,
                 "Prev&nbsp;Class",
                 "Next&nbsp;Class");
 
-        checkOutput("m2p1/class-use/Am2.html", false,
+        checkOutput("m2/m2p1/class-use/Am2.html", false,
                 "Prev",
                 "Next");
 
-        checkOutput("m2p1/package-tree.html", false,
+        checkOutput("m2/m2p1/package-tree.html", false,
                 "Prev",
                 "Next");