Skip to content
Permalink
Browse files
8256208: Javadoc's generated overview does not show classes of unname…
…d package

Reviewed-by: jjg
  • Loading branch information
hns committed Nov 9, 2021
1 parent f65db88 commit e35abe3235ab38985a19545e76c58260ec97c718
Showing 5 changed files with 67 additions and 13 deletions.
@@ -296,12 +296,6 @@ protected void setTopFile() {
} else {
if (showModules) {
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 = docPaths.forClass(te);
}
} else if (!packages.isEmpty()) {
topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
}
@@ -105,13 +105,11 @@ protected void addIndex(Content main) {
}

for (PackageElement pkg : configuration.packages) {
if (!pkg.isUnnamed()) {
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent);
table.addRow(pkg, packageLinkContent, summaryContent);
}
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getLocalizedPackageName(pkg));
Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent);
table.addRow(pkg, packageLinkContent, summaryContent);
}
}

@@ -24,6 +24,7 @@
/*
* @test
* @bug 4904075 4774450 5015144 8043698 8196201 8203791 8184205 8260223
* 8256208
* @summary Reference unnamed package as "Unnamed", not empty string.
* Generate a package summary for the unnamed package.
* @library ../../lib
@@ -48,6 +49,12 @@ public void test() {
testSrc("src1/C.java"));
checkExit(Exit.OK);

checkOutput("index.html", true,
"""
<script type="text/javascript">window.location.replace('package-summary.html')</script>
<noscript>
<meta http-equiv="Refresh" content="0;package-summary.html">
</noscript>""");
checkOutput("package-summary.html", true,
"""
<h1 title="Unnamed Package" class="title">Unnamed Package</h1>""",
@@ -156,4 +163,25 @@ public void testUse() {
eters of type <a href="../A.html" title="class in Unnamed Package">A</a>""");

}

@Test
public void testMixed() {
javadoc("-d", "out-mixed",
"-sourcepath", testSrc("src1"),
testSrc("src1/C.java"),
"pkg");
checkExit(Exit.OK);

checkOutput("index.html", true,
"""
<div class="col-first even-row-color all-packages-table all-packages-table-tab1"\
><a href="package-summary.html">Unnamed Package</a></div>
<div class="col-last even-row-color all-packages-table all-packages-table-tab1">
<div class="block">This is a package comment for the unnamed package.</div>
</div>
<div class="col-first odd-row-color all-packages-table all-packages-table-tab1">\
<a href="pkg/package-summary.html">pkg</a></div>
<div class="col-last odd-row-color all-packages-table all-packages-table-tab1">
<div class="block">This is a package comment for package pkg.</div>""");
}
}
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package pkg;

/**
* This is class D in the package pkg.
*/
public class D {}
@@ -0,0 +1,5 @@
<html>
<body>
This is a package comment for package pkg.
</body>
</html>

1 comment on commit e35abe3

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e35abe3 Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.