8220217: Javadoc missing link to member method
authorhannesw
Mon, 07 Oct 2019 15:58:04 +0200
changeset 58477 d148a7e7160c
parent 58474 74094a60d018
child 58478 78de3ec29f1e
child 58479 35ce0ad5870a
8220217: Javadoc missing link to member method Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.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/VisibleMemberTable.java
test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java
test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg2/DocumentedNonGenericChild.java
test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg2/UndocumentedGenericParent.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java	Mon Oct 07 15:00:24 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/package-info.java	Mon Oct 07 15:58:04 2019 +0200
@@ -25,7 +25,7 @@
 
 /**
  *  Doclets provide the user-selectable backends for processing the
- *  documentation comnments in Java source code.
+ *  documentation comments in Java source code.
  *
  *  <p>Doclets are implementations of the {@link jdk.javadoc.doclet Doclet API}.</p>
  *
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Mon Oct 07 15:00:24 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Mon Oct 07 15:58:04 2019 +0200
@@ -320,7 +320,7 @@
                     //necessary.
                     DocFinder.Output inheritedDoc =
                             DocFinder.search(configuration,
-                                    new DocFinder.Input(utils, (ExecutableElement) member));
+                                    new DocFinder.Input(utils, member));
                     if (inheritedDoc.holder != null
                             && !utils.getFirstSentenceTrees(inheritedDoc.holder).isEmpty()) {
                         // let the comment helper know of the overridden element
@@ -473,7 +473,7 @@
     private void addSummaryFootNote(TypeElement inheritedClass, SortedSet<Element> inheritedMembers,
                                     Content linksTree, MemberSummaryWriter writer) {
         for (Element member : inheritedMembers) {
-            TypeElement t = (utils.isPackagePrivate(inheritedClass) && !utils.isLinkable(inheritedClass))
+            TypeElement t = utils.isUndocumentedEnclosure(inheritedClass)
                     ? typeElement : inheritedClass;
             writer.addInheritedMemberSummary(t, member, inheritedMembers.first() == member,
                     inheritedMembers.last() == member, linksTree);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Mon Oct 07 15:00:24 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Mon Oct 07 15:58:04 2019 +0200
@@ -529,6 +529,10 @@
         return true;
     }
 
+    public boolean isUndocumentedEnclosure(TypeElement enclosingTypeElement) {
+        return isPackagePrivate(enclosingTypeElement) && !isLinkable(enclosingTypeElement);
+    }
+
     public boolean isError(TypeElement te) {
         if (isEnum(te) || isInterface(te) || isAnnotationType(te)) {
             return false;
@@ -1064,8 +1068,7 @@
 
         // Allow for the behavior that members of undocumented supertypes
         // may be included in documented types
-        TypeElement enclElem = getEnclosingTypeElement(elem);
-        if (typeElem != enclElem && isSubclassOf(typeElem, enclElem)) {
+        if (isUndocumentedEnclosure(getEnclosingTypeElement(elem))) {
             return true;
         }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java	Mon Oct 07 15:00:24 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java	Mon Oct 07 15:58:04 2019 +0200
@@ -209,7 +209,7 @@
     public List<? extends Element> getVisibleMembers(Kind kind) {
         Predicate<Element> declaredAndLeafMembers = e -> {
             TypeElement encl = utils.getEnclosingTypeElement(e);
-            return encl == te || isUndocumentedEnclosure(encl);
+            return encl == te || utils.isUndocumentedEnclosure(encl);
         };
         return getVisibleMembers(kind, declaredAndLeafMembers);
     }
@@ -238,7 +238,8 @@
         ensureInitialized();
 
         OverridingMethodInfo found = overriddenMethodTable.get(e);
-        if (found != null && (found.simpleOverride || isUndocumentedEnclosure(utils.getEnclosingTypeElement(e)))) {
+        if (found != null
+                && (found.simpleOverride || utils.isUndocumentedEnclosure(utils.getEnclosingTypeElement(e)))) {
             return found.overrider;
         }
         return null;
@@ -347,10 +348,6 @@
         return pm == null ? null : pm.setter;
     }
 
-    boolean isUndocumentedEnclosure(TypeElement encl) {
-        return utils.isPackagePrivate(encl) && !utils.isLinkable(encl);
-    }
-
     private void computeParents() {
         for (TypeMirror intfType : te.getInterfaces()) {
             TypeElement intfc = utils.asTypeElement(intfType);
@@ -388,7 +385,7 @@
 
     private void computeLeafMembers(LocalMemberTable lmt, Kind kind) {
         List<Element> list = new ArrayList<>();
-        if (isUndocumentedEnclosure(te)) {
+        if (utils.isUndocumentedEnclosure(te)) {
             list.addAll(lmt.getOrderedMembers(kind));
         }
         parents.forEach(pvmt -> {
@@ -617,7 +614,7 @@
 
                 // Disallow package-private super methods to leak in
                 TypeElement encl = utils.getEnclosingTypeElement(inheritedMethod);
-                if (isUndocumentedEnclosure(encl)) {
+                if (utils.isUndocumentedEnclosure(encl)) {
                     overriddenMethodTable.computeIfAbsent(lMethod,
                             l -> new OverridingMethodInfo(inheritedMethod, false));
                     return false;
--- a/test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java	Mon Oct 07 15:00:24 2019 +0200
+++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java	Mon Oct 07 15:58:04 2019 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200
- *      8192850 8182765
+ *      8192850 8182765 8220217
  * @summary Test to make sure that members are inherited properly in the Javadoc.
  *          Verify that inheritance labels are correct.
  * @author jamieh
@@ -47,7 +47,7 @@
     public void test() {
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
-                "pkg", "diamond", "inheritDist", "pkg1");
+                "pkg", "diamond", "inheritDist", "pkg1", "pkg2");
         checkExit(Exit.OK);
 
         checkOutput("pkg/SubClass.html", true,
@@ -104,5 +104,27 @@
                 + "<code><a href=\"Interface.html#between(java.time.chrono.ChronoLocalDate"
                 + ",java.time.chrono.ChronoLocalDate)\">between</a></code>"
         );
+
+        checkOutput("pkg2/DocumentedNonGenericChild.html", true,
+                "<section class=\"description\">\n<hr>\n"
+                + "<pre>public abstract class <span class=\"typeNameLabel\">"
+                + "DocumentedNonGenericChild</span>\n"
+                + "extends java.lang.Object</pre>\n"
+                + "</section>");
+
+        checkOutput("pkg2/DocumentedNonGenericChild.html", true,
+                "<td class=\"colFirst\"><code>protected abstract java.lang.String</code></td>\n"
+                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"#parentMethod()\">parentMethod</a></span>()</code></th>\n"
+                + "<td class=\"colLast\">\n"
+                + "<div class=\"block\">Returns some value.</div>\n"
+                + "</td>\n");
+
+        checkOutput("pkg2/DocumentedNonGenericChild.html", true,
+                "<h3><a id=\"parentMethod()\">parentMethod</a></h3>\n"
+                + "<div class=\"memberSignature\"><span class=\"modifiers\">protected abstract</span>"
+                + "&nbsp;<span class=\"returnType\">java.lang.String</span>&nbsp;"
+                + "<span class=\"memberName\">parentMethod</span>()</div>");
+
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg2/DocumentedNonGenericChild.java	Mon Oct 07 15:58:04 2019 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, 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 pkg2;
+
+public abstract class DocumentedNonGenericChild extends UndocumentedGenericParent<String> {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/pkg2/UndocumentedGenericParent.java	Mon Oct 07 15:58:04 2019 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019, 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 pkg2;
+
+abstract class UndocumentedGenericParent<T> {
+    /**
+     * Returns some value.
+     *
+     * @return some value
+     */
+    protected abstract String parentMethod();
+}