diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java index 16d7250557e..e5a733c23d1 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package jdk.javadoc.internal.doclets.formats.html; +import java.util.Collections; import java.util.EnumSet; import java.util.LinkedHashMap; import java.util.List; @@ -284,12 +285,14 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW additionalModules.remove(m); } }); + // Get all packages for the module and put it in the concealed packages set. - (utils.getModulePackageMap().get(mdle)).forEach((pkg) -> { + utils.getModulePackageMap().getOrDefault(mdle, Collections.emptySet()).forEach((pkg) -> { if (shouldDocument(pkg)) { concealedPackages.add(pkg); } }); + // Get all exported packages for the module using the exports directive for the module. (ElementFilter.exportsIn(mdle.getDirectives())).forEach((directive) -> { PackageElement p = directive.getPackage(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java index 2b538374422..f65440b4189 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java @@ -441,6 +441,11 @@ public abstract class Configuration { } } + // add entries for modules which may not have exported packages + modules.forEach((ModuleElement mdle) -> { + modulePackages.computeIfAbsent(mdle, m -> Collections.emptySet()); + }); + modules.addAll(modulePackages.keySet()); showModules = !modules.isEmpty(); for (Set pkgs : modulePackages.values()) { diff --git a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java index 1636f77be25..fa5e7dfc1e6 100644 --- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java +++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java @@ -24,7 +24,7 @@ /* * @test * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363 - * 8168766 8168688 8162674 8160196 8175799 8174974 + * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 * @summary Test modules support in javadoc. * @author bpatel * @library ../lib @@ -181,6 +181,19 @@ public class TestModules extends JavadocTester { checkNegatedModuleSummary(); } + /** + * Test generated module summary page of an aggregating module. + */ + @Test + void testAggregatorModuleSummary() { + javadoc("-d", "out-aggregatorModuleSummary", "-use", + "--module-source-path", testSrc, + "--expand-requires", "transitive", + "--module", "moduleT"); + checkExit(Exit.OK); + checkAggregatorModuleSummary(); + } + /** * Test generated module pages and pages with link to modules. */ @@ -599,6 +612,32 @@ public class TestModules extends JavadocTester { + ""); } + void checkAggregatorModuleSummary() { + checkOutput("moduleT-summary.html", true, + "
\n" + + "

Module moduleT

\n" + + "
", + "
This is a test description for the moduleT module. " + + "Search phrase search phrase. " + + "Make sure there are no exported packages.
", + "\n" + + "\n" + + "transitive\n" + + "moduleA\n" + + "\n" + + "
This is a test description for the moduleA module.
\n" + + "\n" + + "\n" + + "\n" + + "transitive\n" + + "moduleB\n" + + "\n" + + "
This is a test description for the moduleB module.
\n" + + "\n" + + "\n" + + ""); + } + void checkNegatedModuleSummary() { checkOutput("moduleA-summary.html", false, "\n" diff --git a/langtools/test/jdk/javadoc/doclet/testModules/moduleT/module-info.java b/langtools/test/jdk/javadoc/doclet/testModules/moduleT/module-info.java new file mode 100644 index 00000000000..653c11b2c0a --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testModules/moduleT/module-info.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * This is a test description for the moduleT module. Search phrase {@index "search phrase" with description}. Make sure there are no exported packages. + * + */ +module moduleT { + requires transitive moduleA; + requires transitive moduleB; +}