Skip to content

Commit a27ee6b

Browse files
committedJun 16, 2020
8236539: Relative link tags in record javadoc don't resolve
Reviewed-by: hannesw
1 parent dee90e4 commit a27ee6b

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
 

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

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ protected void addElementDescription(IndexItem indexItem, Content dlTree, Search
159159
break;
160160
case CLASS:
161161
case ENUM:
162+
case RECORD:
162163
case ANNOTATION_TYPE:
163164
case INTERFACE:
164165
dt = HtmlTree.DT(getLink(new LinkInfoImpl(configuration,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright (c) 2020, 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 8236539
27+
* @summary Relative link tags in record javadoc don't resolve
28+
* @library /tools/lib ../../lib
29+
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30+
* @build toolbox.ToolBox javadoc.tester.*
31+
* @compile --enable-preview --source ${jdk.version} TestRecordLinks.java
32+
* @run main/othervm --enable-preview TestRecordLinks
33+
*/
34+
35+
import java.nio.file.Path;
36+
37+
import javadoc.tester.JavadocTester;
38+
import toolbox.ToolBox;
39+
40+
public class TestRecordLinks extends JavadocTester {
41+
public static void main(String... args) throws Exception {
42+
TestRecordLinks tester = new TestRecordLinks();
43+
tester.runTests(m -> new Object[] { Path.of(m.getName()) });
44+
}
45+
46+
private final ToolBox tb = new ToolBox();
47+
48+
@Test
49+
public void testCrash(Path base) throws Exception {
50+
// from JDK-8236539
51+
String example = """
52+
package example;
53+
public class JavadocTest {
54+
/**
55+
* {@link #foo()}
56+
* {@link Bar}
57+
*/
58+
public static class Foo {
59+
public void foo() { }
60+
}
61+
62+
/**
63+
* {@link #bar()}
64+
* {@link Foo}
65+
*/
66+
public record Bar() {
67+
public void bar() { }
68+
}
69+
}
70+
""";
71+
72+
Path src = base.resolve("src");
73+
tb.writeJavaFiles(src, example);
74+
75+
javadoc("-d", base.resolve("out").toString(),
76+
"-sourcepath", src.toString(),
77+
"--enable-preview", "--source", thisRelease,
78+
"example");
79+
checkExit(Exit.OK);
80+
81+
checkOutput("example/JavadocTest.Foo.html", true,
82+
"""
83+
<h1 title="Class JavadocTest.Foo" class="title">Class JavadocTest.Foo</h1>
84+
""",
85+
"""
86+
<div class="block"><a href="#foo()"><code>foo()</code></a>
87+
<a href="JavadocTest.Bar.html" title="class in example"><code>JavadocTest.Bar</code></a></div>
88+
""");
89+
90+
checkOutput("example/JavadocTest.Bar.html", true,
91+
"""
92+
<h1 title="Record JavadocTest.Bar" class="title">Record JavadocTest.Bar</h1>
93+
""",
94+
"""
95+
<div class="block"><a href="#bar()"><code>bar()</code></a>
96+
<a href="JavadocTest.Foo.html" title="class in example"><code>JavadocTest.Foo</code></a></div>
97+
""");
98+
}
99+
}

0 commit comments

Comments
 (0)
Please sign in to comment.