From db0857ddd8653cb3244d63064da16537126dab4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 5 Jun 2023 09:39:19 +0000 Subject: [PATCH] 8306578: Report error if no label given in @see and {@link} when no default is available Reviewed-by: jjg --- .../internal/doclets/formats/html/TagletWriterImpl.java | 2 +- .../doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index fead3a828441c..fa466e723b98b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -494,7 +494,7 @@ private Content linkSeeReferenceOutput(Element holder, if (labelContent.isEmpty()) { // A non-empty label is required for fragment links as the // reference target does not provide a useful default label. - reportWarning.accept("doclet.link.see.no_label", null); + htmlWriter.messages.error(ch.getDocTreePath(refTree), "doclet.link.see.no_label"); return invalidTagOutput(resources.getText("doclet.link.see.no_label"), Optional.of(refSignature)); } diff --git a/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java b/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java index c480130cf23ce..4fc515f9427dc 100644 --- a/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java +++ b/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8200337 8307377 + * @bug 8200337 8307377 8306578 * @summary Generalize see and link tags for user-defined anchors * @library /tools/lib ../../lib * @modules @@ -140,14 +140,14 @@ public void testMissingLabel(Path base) throws Exception { "--no-platform-links", "nolabel"); - checkExit(Exit.OK); + checkExit(Exit.ERROR); checkOutput(Output.OUT, true, """ - warning: missing reference label + error: missing reference label Link with missing label: {@link ##main}. ^ """, """ - Class1.java:5: warning: missing reference label + Class1.java:5: error: missing reference label @see ##main ^ """);