Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk19 Public archive

Commit 983f75c

Browse files
committedJun 17, 2022
8288545: Missing space in error message
Reviewed-by: hannesw
1 parent 53bf1bf commit 983f75c

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed
 

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -978,11 +978,15 @@ public Content seeTagToContent(Element element, DocTree see, TagletWriterImpl.Co
978978
String tagName = ch.getTagName(see);
979979

980980
String seeText = utils.normalizeNewlines(ch.getText(see)).toString();
981+
String refText;
981982
List<? extends DocTree> label;
982983
switch (kind) {
983-
case LINK, LINK_PLAIN ->
984+
case LINK, LINK_PLAIN -> {
984985
// {@link[plain] reference label...}
985-
label = ((LinkTree) see).getLabel();
986+
LinkTree lt = (LinkTree) see;
987+
refText = lt.getReference().toString();
988+
label = lt.getLabel();
989+
}
986990

987991
case SEE -> {
988992
List<? extends DocTree> ref = ((SeeTree) see).getReference();
@@ -998,6 +1002,7 @@ public Content seeTagToContent(Element element, DocTree see, TagletWriterImpl.Co
9981002
}
9991003
case REFERENCE -> {
10001004
// @see reference label...
1005+
refText = ref.get(0).toString();
10011006
label = ref.subList(1, ref.size());
10021007
}
10031008
case ERRONEOUS -> {
@@ -1058,7 +1063,7 @@ public Content seeTagToContent(Element element, DocTree see, TagletWriterImpl.Co
10581063
messages.warning(ch.getDocTreePath(see),
10591064
"doclet.see.class_or_package_not_found",
10601065
"@" + tagName,
1061-
seeText);
1066+
refText);
10621067
}
10631068
return invalidTagOutput(resources.getText("doclet.tag.invalid", tagName),
10641069
Optional.of(labelContent.isEmpty() ? text: labelContent));
@@ -1112,7 +1117,7 @@ public Content seeTagToContent(Element element, DocTree see, TagletWriterImpl.Co
11121117
if (!configuration.isDocLintReferenceGroupEnabled()) {
11131118
messages.warning(
11141119
ch.getDocTreePath(see), "doclet.see.class_or_package_not_found",
1115-
tagName, seeText);
1120+
tagName, refText);
11161121
}
11171122
}
11181123
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8288545
27+
* @summary Missing space in error message
28+
* @library /tools/lib ../../lib
29+
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30+
* @build toolbox.ToolBox javadoc.tester.*
31+
* @run main TestLinkNotFound
32+
*/
33+
34+
import javadoc.tester.JavadocTester;
35+
import toolbox.ToolBox;
36+
37+
import java.nio.file.Path;
38+
39+
public class TestLinkNotFound extends JavadocTester {
40+
41+
public static void main(String... args) throws Exception {
42+
TestLinkNotFound tester = new TestLinkNotFound();
43+
tester.runTests();
44+
}
45+
46+
ToolBox tb = new ToolBox();
47+
48+
@Test
49+
public void test(Path base) throws Exception {
50+
Path src = base.resolve("src");
51+
tb.writeJavaFiles(src,
52+
"""
53+
/**
54+
* Comment.
55+
* {@link nowhere label}
56+
*/
57+
public class C{ }
58+
""");
59+
60+
javadoc("-d", base.resolve("api").toString(),
61+
"-Xdoclint:none",
62+
"-Werror",
63+
"-sourcepath", src.toString(),
64+
src.resolve("C.java").toString());
65+
checkExit(Exit.ERROR);
66+
67+
// the use of '\n' in the following check implies that the label does not appear after the reference
68+
checkOutput(Output.OUT, true,
69+
"reference not found: nowhere\n");
70+
}
71+
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jun 17, 2022

@openjdk-notifier[bot]
This repository has been archived.