# HG changeset patch # User jjg # Date 1498528111 25200 # Node ID e447c20c3ff9e3ee9fd88ef352e70a52a3cffe29 # Parent 51bca2b0d672016c180f790aade2e993ce3d265c 8182736: javadoc generates bad names and broken module graph links Reviewed-by: jjg, bpatel, darcy, ksrini Contributed-by: bhavesh.patel@oracle.com, jonathan.gibbons@oracle.com diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Mon Jun 26 18:48:31 2017 -0700 @@ -140,7 +140,9 @@ int j = 0; Content dl = new HtmlTree(HtmlTag.DL); while (i < memberListSize && j < searchListSize) { - String name = utils.getSimpleName(memberlist.get(i)); + Element elem = memberlist.get(i); + String name = (utils.isModule(elem)) + ? utils.getFullyQualifiedName(elem) : utils.getSimpleName(elem); if (name.compareTo(searchList.get(j).getLabel()) < 0) { addDescription(dl, memberlist.get(i)); i++; @@ -222,7 +224,7 @@ * @param dlTree the content tree to which the description will be added */ protected void addDescription(ModuleElement mdle, Content dlTree, SearchIndexItem si) { - String moduleName = utils.getSimpleName(mdle); + String moduleName = utils.getFullyQualifiedName(mdle); Content link = getModuleLink(mdle, new StringContent(moduleName)); si.setLabel(moduleName); si.setCategory(resources.getText("doclet.Modules")); @@ -246,7 +248,7 @@ protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) { Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); if (configuration.showModules) { - si.setContainingModule(utils.getSimpleName(utils.containingModule(pkg))); + si.setContainingModule(utils.getFullyQualifiedName(utils.containingModule(pkg))); } si.setLabel(utils.getPackageName(pkg)); si.setCategory(resources.getText("doclet.Packages")); diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java Mon Jun 26 18:48:31 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,7 @@ @Override public Void visitModule(ModuleElement e, Void p) { si.setUrl(DocPaths.moduleSummary(e).getPath() + "#" + anchorName); - si.setHolder(utils.getSimpleName(element)); + si.setHolder(utils.getFullyQualifiedName(element)); return null; } diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java Mon Jun 26 18:48:31 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,7 +131,7 @@ * @throws DocletException if there is a problem while building the documentation */ public void buildModuleDoc(XMLNode node, Content contentTree) throws DocletException { - contentTree = moduleWriter.getModuleHeader(mdle.getSimpleName().toString()); + contentTree = moduleWriter.getModuleHeader(mdle.getQualifiedName().toString()); buildChildren(node, contentTree); moduleWriter.addModuleFooter(contentTree); moduleWriter.printDocument(contentTree); diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java Mon Jun 26 18:48:31 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -199,7 +199,7 @@ */ protected void addModulesToIndexMap() { for (ModuleElement mdle : configuration.modules) { - String mdleName = mdle.getSimpleName().toString(); + String mdleName = mdle.getQualifiedName().toString(); char ch = (mdleName.length() == 0) ? '*' : Character.toUpperCase(mdleName.charAt(0)); diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Mon Jun 26 18:48:31 2017 -0700 @@ -1682,7 +1682,7 @@ return new Utils.ElementComparator() { @Override public int compare(Element mod1, Element mod2) { - return compareNames(mod1, mod2); + return compareFullyQualifiedNames(mod1, mod2); } }; } @@ -1772,9 +1772,8 @@ /** * Returns a Comparator for index file presentations, and are sorted as follows. - * If comparing modules then simply compare the simple names, - * comparing packages then simply compare the qualified names, if comparing a package with a - * module/type/member then compare the FullyQualifiedName of the package + * If comparing modules and packages then simply compare the qualified names, if comparing a module + * or a package with a type/member then compare the FullyQualifiedName of the module or a package * with the SimpleName of the entity, otherwise * 1. compare the ElementKind ex: Module, Package, Interface etc. * 2a. if equal and if the type is of ExecutableElement(Constructor, Methods), @@ -1786,10 +1785,9 @@ public Comparator makeIndexUseComparator() { return new Utils.ElementComparator() { /** - * Compare two given elements, if comparing two modules, return the - * comparison of SimpleName, if comparing two packages, return the - * comparison of FullyQualifiedName, if comparing a package with a - * module/type/member then compare the FullyQualifiedName of the package + * Compare two given elements, if comparing two modules or two packages, return the + * comparison of FullyQualifiedName, if comparing a module or a package with a + * type/member then compare the FullyQualifiedName of the module or the package * with the SimpleName of the entity, then sort on the kinds, then on * the parameters only if the type is an ExecutableElement, * the parameters are compared and finally the qualified names. @@ -1802,16 +1800,17 @@ @Override public int compare(Element e1, Element e2) { int result = 0; - if (isModule(e1) && isModule(e2)) { - return compareNames(e1, e2); + if ((isModule(e1) || isPackage(e1)) && (isModule(e2) || isPackage(e2))) { + result = compareFullyQualifiedNames(e1, e2); + if (result != 0) { + return result; + } + return compareElementTypeKinds(e1, e2); } - if (isPackage(e1) && isPackage(e2)) { - return compareFullyQualifiedNames(e1, e2); - } - if (isPackage(e1) || isPackage(e2)) { - result = (isPackage(e1)) - ? compareStrings(getFullyQualifiedName(e1), getSimpleName(e2)) - : compareStrings(getSimpleName(e1), getFullyQualifiedName(e2)); + if (isModule(e1) || isPackage(e1)) { + result = compareStrings(getFullyQualifiedName(e1), getSimpleName(e2)); + } else if (isModule(e2) || isPackage(e2)) { + result = compareStrings(getSimpleName(e1), getFullyQualifiedName(e2)); } else { result = compareNames(e1, e2); } @@ -1916,6 +1915,11 @@ public String getFullyQualifiedName(Element e, final boolean outer) { return new SimpleElementVisitor9() { @Override + public String visitModule(ModuleElement e, Void p) { + return e.getQualifiedName().toString(); + } + + @Override public String visitPackage(PackageElement e, Void p) { return e.getQualifiedName().toString(); } @@ -2527,7 +2531,7 @@ snvisitor = new SimpleElementVisitor9() { @Override public String visitModule(ModuleElement e, Void p) { - return e.getSimpleName().toString(); + return e.getQualifiedName().toString(); // temp fix for 8182736 } @Override diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/test/jdk/javadoc/doclet/testModules/TestModules.java --- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Thu Jun 22 18:42:48 2017 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java Mon Jun 26 18:48:31 2017 -0700 @@ -372,7 +372,20 @@ "--module", "moduleB", "testpkg2mdlB", "testpkgmdlB"); checkExit(Exit.OK); - //checkOverviewSummaryPackages(); + checkGroupOptionSingleModule(); + } + + /** + * Test -group option for a single module. + */ + @Test + void testModuleName() { + javadoc("-d", "out-modulename", "-use", + "--module-source-path", testSrc, + "--module", "moduleB,test.moduleFullName", + "testpkg2mdlB", "testpkgmdlB", "testpkgmdlfullname"); + checkExit(Exit.OK); + checkModuleName(true); } void checkDescription(boolean found) { @@ -1089,4 +1102,35 @@ "\n" + ""); } + + void checkModuleName(boolean found) { + checkOutput("test.moduleFullName-summary.html", found, + "
\n" + + "

Module test.moduleFullName

\n" + + "
"); + checkOutput("index-all.html", found, + "

T

\n" + + "
\n" + + "
test.moduleFullName - module test.moduleFullName
\n" + + "
\n" + + "
This is a test description for the test.moduleFullName.
\n" + + "
"); + checkOutput("module-overview-frame.html", found, + "

Modules

\n" + + ""); + checkOutput("test.moduleFullName-summary.html", !found, + "
\n" + + "

Module moduleFullName

\n" + + "
"); + checkOutput("index-all.html", !found, + "
\n" + + "
moduleFullName - module moduleFullName
\n" + + "
\n" + + "
This is a test description for the test.moduleFullName.
\n" + + "
\n" + + "
"); } +} diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/test/jdk/javadoc/doclet/testModules/test.moduleFullName/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testModules/test.moduleFullName/module-info.java Mon Jun 26 18:48:31 2017 -0700 @@ -0,0 +1,32 @@ +/* + * 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 test.moduleFullName. + * + */ +module test.moduleFullName { + exports testpkgmdlfullname; +} diff -r 51bca2b0d672 -r e447c20c3ff9 langtools/test/jdk/javadoc/doclet/testModules/test.moduleFullName/testpkgmdlfullname/TestClassInTestModuleFullName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testModules/test.moduleFullName/testpkgmdlfullname/TestClassInTestModuleFullName.java Mon Jun 26 18:48:31 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 testpkgmdlfullname; + +public class TestClassInTestModuleFullName { + public void testMethod() { } +}
Modules