changeset 4104:d2f92cb767a6

8175823: doclet crashes when documenting a single class in a module. Reviewed-by: jjg, ksrini
author bpatel
date Fri, 14 Apr 2017 17:23:55 -0700
parents ad2910e96239
children 8b68fb0d8159
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java test/jdk/javadoc/doclet/testModules/TestModules.java test/jdk/javadoc/doclet/testModules/moduleNoExport/module-info.java test/jdk/javadoc/doclet/testModules/moduleNoExport/testpkgmdlNoExport/TestClassInModuleNoExport.java
diffstat 4 files changed, 102 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Fri Apr 14 15:54:01 2017 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Fri Apr 14 17:23:55 2017 -0700
@@ -290,7 +290,7 @@
 
         // Get all packages for the module and put it in the concealed packages set.
         utils.getModulePackageMap().getOrDefault(mdle, Collections.emptySet()).forEach((pkg) -> {
-            if (shouldDocument(pkg)) {
+            if (shouldDocument(pkg) && moduleMode == ModuleMode.ALL) {
                 concealedPackages.add(pkg);
             }
         });
@@ -309,7 +309,9 @@
                 if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) {
                     exportedPackages.put(p, mdleList);
                 }
-                concealedPackages.remove(p);
+                if (moduleMode == ModuleMode.ALL) {
+                    concealedPackages.remove(p);
+                }
             }
         });
         // Get all opened packages for the module using the opens directive for the module.
@@ -326,12 +328,11 @@
                 if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) {
                     openedPackages.put(p, mdleList);
                 }
-                concealedPackages.remove(p);
+                if (moduleMode == ModuleMode.ALL) {
+                    concealedPackages.remove(p);
+                }
             }
         });
-        // Remove all the exported and opened packages so we have just the concealed packages now.
-        concealedPackages.removeAll(exportedPackages.keySet());
-        concealedPackages.removeAll(openedPackages.keySet());
         // Get all the exported and opened packages, for the transitive closure of the module, to be displayed in
         // the indirect packages tables.
         dependentModules.forEach((module, mod) -> {
--- a/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Apr 14 15:54:01 2017 -0700
+++ b/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Apr 14 17:23:55 2017 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
- *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
+ *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 8175823
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -270,6 +270,32 @@
         checkModuleModeAll(true);
     }
 
+    /**
+     * Test generated module summary page of a module with no exported package.
+     */
+    @Test
+    void testModuleSummaryNoExportedPkgAll() {
+        javadoc("-d", "out-ModuleSummaryNoExportedPkgAll", "-use", "--show-module-contents=all",
+                "-sourcepath", testSrc + "/moduleNoExport",
+                "--module", "moduleNoExport",
+                "testpkgmdlNoExport");
+        checkExit(Exit.OK);
+        checkModuleSummaryNoExported(true);
+    }
+
+    /**
+     * Test generated module summary page of a module with no exported package.
+     */
+    @Test
+    void testModuleSummaryNoExportedPkgApi() {
+        javadoc("-d", "out-ModuleSummaryNoExportedPkgApi", "-use",
+                "-sourcepath", testSrc + "/moduleNoExport",
+                "--module", "moduleNoExport",
+                "testpkgmdlNoExport");
+        checkExit(Exit.OK);
+        checkModuleSummaryNoExported(false);
+    }
+
     void checkDescription(boolean found) {
         checkOutput("moduleA-summary.html", found,
                 "<!-- ============ MODULE DESCRIPTION =========== -->\n"
@@ -901,4 +927,13 @@
         checkOutput("index.html", found,
                 "<iframe src=\"module-overview-frame.html\" name=\"packageListFrame\" title=\"All Modules\"></iframe>");
     }
+
+    void checkModuleSummaryNoExported(boolean found) {
+        checkOutput("moduleNoExport-summary.html", found,
+                "<!-- ============ PACKAGES SUMMARY =========== -->\n"
+                + "<a name=\"packages.summary\">\n"
+                + "<!--   -->\n"
+                + "</a>",
+                "<caption><span>Concealed</span><span class=\"tabEnd\">&nbsp;</span></caption>");
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javadoc/doclet/testModules/moduleNoExport/module-info.java	Fri Apr 14 17:23:55 2017 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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 moduleNoExport module. Make sure there are no exported packages.
+  */
+module moduleNoExport {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javadoc/doclet/testModules/moduleNoExport/testpkgmdlNoExport/TestClassInModuleNoExport.java	Fri Apr 14 17:23:55 2017 -0700
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+package testpkgmdlNoExport;
+
+public class TestClassInModuleNoExport {
+    public void testMethodClassModuleNoExport() { }
+}