diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java index 15e88da5bae..c171e10132a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java @@ -254,16 +254,13 @@ public class LinkTaglet extends BaseTaglet { // documented, this must be an inherited link. Redirect it. // The current class either overrides the referenced member or // inherits it automatically. - if (htmlWriter instanceof ClassWriter cw) { - containing = cw.getTypeElement(); - } else if (!utils.isPublic(containing)) { - reportWarning.accept("doclet.link.see.reference_not_accessible", - new Object[] { utils.getFullyQualifiedName(containing)}); - } else { - if (!config.isDocLintReferenceGroupEnabled()) { - reportWarning.accept("doclet.link.see.reference_not_found", - new Object[] { refSignature }); + if (utils.configuration.docEnv.isSelected(refMem)) { + if (htmlWriter instanceof ClassWriter cw) { + containing = cw.getTypeElement(); } + } else { + reportWarning.accept("doclet.link.see.reference_not_accessible", + new Object[]{refMem}); } } String refMemName = refFragment; diff --git a/test/langtools/jdk/javadoc/doclet/5093723/DocumentedClass.java b/test/langtools/jdk/javadoc/doclet/5093723/DocumentedClass.java deleted file mode 100644 index 659cbb77f40..00000000000 --- a/test/langtools/jdk/javadoc/doclet/5093723/DocumentedClass.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2009 Google, Inc. 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. - */ - -/** A documented class. */ -public class DocumentedClass extends UndocumentedClass { - /** {@link #method} */ - public void m1() {} - /** {@link #publicMethod} */ - public void m2() {} - /** {@link #protectedMethod} */ - public void m3() {} - /** {@link #privateMethod} */ - public void m4() {} -} diff --git a/test/langtools/jdk/javadoc/doclet/5093723/T5093723.java b/test/langtools/jdk/javadoc/doclet/5093723/T5093723.java index f27b716ded1..9f0ed70e25a 100644 --- a/test/langtools/jdk/javadoc/doclet/5093723/T5093723.java +++ b/test/langtools/jdk/javadoc/doclet/5093723/T5093723.java @@ -1,5 +1,6 @@ /* * Copyright 2009 Google, Inc. All Rights Reserved. + * Copyright (c) 2013, 2024, 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 @@ -23,30 +24,85 @@ /* * @test - * @bug 5093723 + * @bug 5093723 8202617 * @summary REGRESSION: ClassCastException in SingleIndexWriter - * @library ../../lib + * Check that links to undocumented members are not generated + * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build javadoc.tester.* + * @build toolbox.ToolBox javadoc.tester.* * @run main T5093723 */ import javadoc.tester.JavadocTester; +import toolbox.ToolBox; + +import java.io.IOException; +import java.nio.file.Path; + public class T5093723 extends JavadocTester { + ToolBox tb = new ToolBox(); + public static void main(String... args) throws Exception { var tester = new T5093723(); tester.runTests(); } @Test - public void test() { - setAutomaticCheckLinks(false); // @ignore JDK-8202617 + public void test(Path base) throws IOException { + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, """ + package p; + /** A documented class. */ + public class DocumentedClass extends UndocumentedClass { + /** {@link #method} */ + public void m1() {} + /** {@link #publicMethod} */ + public void m2() {} + /** {@link #protectedMethod} */ + public void m3() {} + /** {@link #privateMethod} */ + public void m4() {} + } + """, """ + package p; + class UndocumentedClass { + void method() {} + public void publicMethod() {} + protected void protectedMethod() {} + private void privateMethod() {} + } + """); + javadoc("-d", "out", "-Xdoclint:none", - testSrc("DocumentedClass.java"), - testSrc("UndocumentedClass.java")); + "-sourcepath", + src.toString(), + "p"); checkExit(Exit.OK); + + checkOutput("p/DocumentedClass.html", + true, + "
UndocumentedClass.method()UndocumentedClass.privateMethod()