Skip to content

Commit bc857cb

Browse files
committed
8281944: JavaDoc throws java.lang.IllegalStateException: ERRONEOUS
Reviewed-by: jjg Backport-of: 0796620b07c6287a130ab0a3a7279d69b5d7b8a1
1 parent bcd19a5 commit bc857cb

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ public Content seeTagToContent(Element element, DocTree see, TagletWriterImpl.Co
10151015
// @see reference label...
10161016
label = ref.subList(1, ref.size());
10171017
}
1018+
case ERRONEOUS -> {
1019+
messages.warning(ch.getDocTreePath(see),
1020+
"doclet.tag.invalid_input",
1021+
"@" + tagName,
1022+
seeText);
1023+
return Text.of("invalid input: '" + seeText + "'");
1024+
}
10181025
default ->
10191026
throw new IllegalStateException(ref.get(0).getKind().toString());
10201027
}

test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,19 @@
2323

2424
/*
2525
* @test
26-
* @bug 8017191 8182765 8200432 8239804 8250766 8262992
26+
* @bug 8017191 8182765 8200432 8239804 8250766 8262992 8281944
2727
* @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages
28-
* @library ../../lib
28+
* @library /tools/lib ../../lib
2929
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30-
* @build javadoc.tester.*
30+
* @build toolbox.ToolBox javadoc.tester.*
3131
* @run main TestSeeTag
3232
*/
3333

3434
import javadoc.tester.JavadocTester;
35+
import toolbox.ToolBox;
36+
37+
import java.io.IOException;
38+
import java.nio.file.Path;
3539

3640
public class TestSeeTag extends JavadocTester {
3741

@@ -105,4 +109,40 @@ public void testBadReference() {
105109
</dd>
106110
</dl>""");
107111
}
112+
113+
ToolBox tb = new ToolBox();
114+
115+
@Test
116+
public void testErroneous() throws IOException {
117+
Path src = Path.of("erroneous", "src");
118+
tb.writeJavaFiles(src, """
119+
package erroneous;
120+
/**
121+
* Comment.
122+
* @see <a href="
123+
*/
124+
public class C {
125+
private C() { }
126+
}
127+
""");
128+
129+
javadoc("-d", Path.of("erroneous", "api").toString(),
130+
"-sourcepath", src.toString(),
131+
"--no-platform-links",
132+
"erroneous");
133+
checkExit(Exit.ERROR);
134+
135+
checkOutput("erroneous/C.html", true,
136+
"""
137+
<dl class="notes">
138+
<dt>See Also:</dt>
139+
<dd>
140+
<ul class="see-list">
141+
<li>invalid input: '&lt;a href="'</li>
142+
</ul>
143+
</dd>
144+
</dl>
145+
""");
146+
147+
}
108148
}

0 commit comments

Comments
 (0)