Skip to content

Commit 1407160

Browse files
committedAug 9, 2024
8313931: Javadoc: links to type parameters actually generate links to classes
Reviewed-by: jjg
1 parent c37e863 commit 1407160

File tree

26 files changed

+336
-91
lines changed

26 files changed

+336
-91
lines changed
 

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

+39-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import javax.lang.model.element.Name;
3838
import javax.lang.model.element.PackageElement;
3939
import javax.lang.model.element.TypeElement;
40+
import javax.lang.model.element.TypeParameterElement;
4041
import javax.lang.model.element.VariableElement;
4142
import javax.lang.model.type.TypeMirror;
4243
import javax.lang.model.util.SimpleElementVisitor8;
@@ -155,7 +156,7 @@ protected void buildClassTree(Content classContent) {
155156
* @param target the content to which the documentation will be added
156157
*/
157158
protected void buildClassInfo(Content target) {
158-
Content c = HtmlTree.DIV(HtmlStyles.horizontalScroll);
159+
var c = new ContentBuilder();
159160
buildParamInfo(c);
160161
buildSuperInterfacesInfo(c);
161162
buildImplementedInterfacesInfo(c);
@@ -164,11 +165,13 @@ protected void buildClassInfo(Content target) {
164165
buildInterfaceUsageInfo(c);
165166
buildNestedClassInfo(c);
166167
buildFunctionalInterfaceInfo(c);
167-
buildClassSignature(c);
168-
buildDeprecationInfo(c);
169-
buildClassDescription(c);
170-
buildClassTagInfo(c);
171-
168+
c.add(new HtmlTree(HtmlTag.HR));
169+
var div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
170+
buildClassSignature(div);
171+
buildDeprecationInfo(div);
172+
buildClassDescription(div);
173+
buildClassTagInfo(div);
174+
c.add(div);
172175
target.add(getClassInfo(c));
173176
}
174177

@@ -432,19 +435,45 @@ private void setRecordDocumentation(TypeElement elem) {
432435
protected Content getHeader(String header) {
433436
HtmlTree body = getBody(getWindowTitle(utils.getSimpleName(typeElement)));
434437
var div = HtmlTree.DIV(HtmlStyles.header);
435-
HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration,
436-
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement)
437-
.linkToSelf(false); // Let's not link to ourselves in the header
438438
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
439439
HtmlStyles.title, Text.of(header));
440-
heading.add(getTypeParameterLinks(linkInfo));
440+
heading.add(getTypeParameters());
441441
div.add(heading);
442442
bodyContents.setHeader(getHeader(PageMode.CLASS, typeElement))
443443
.addMainContent(MarkerComments.START_OF_CLASS_DATA)
444444
.addMainContent(div);
445445
return body;
446446
}
447447

448+
// Renders type parameters for the class heading, creating id attributes
449+
// if @param block tags are missing in doc comment.
450+
private Content getTypeParameters() {
451+
var content = new ContentBuilder();
452+
var typeParams = typeElement.getTypeParameters();
453+
if (!typeParams.isEmpty()) {
454+
// Generate id attributes if @param tags are missing for type parameters.
455+
// Note that this does not handle the case where some but not all @param tags are missing.
456+
var needsId = !utils.hasBlockTag(typeElement, DocTree.Kind.PARAM);
457+
var linkInfo = new HtmlLinkInfo(configuration,
458+
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_AND_BOUNDS, typeElement)
459+
.linkToSelf(false); // Let's not link to ourselves in the header
460+
content.add("<");
461+
var first = true;
462+
for (TypeParameterElement t : typeParams) {
463+
if (!first) {
464+
content.add(",").add(new HtmlTree(HtmlTag.WBR));
465+
}
466+
var typeParamLink = getLink(linkInfo.forType(t.asType()));
467+
content.add(needsId
468+
? HtmlTree.SPAN_ID(htmlIds.forTypeParam(t.getSimpleName().toString(), typeElement), typeParamLink)
469+
: typeParamLink);
470+
first = false;
471+
}
472+
content.add(">");
473+
}
474+
return content;
475+
}
476+
448477
protected Content getClassContentHeader() {
449478
return getContentHeader();
450479
}
@@ -473,7 +502,6 @@ public TypeElement getCurrentPageElement() {
473502
}
474503

475504
protected void addClassSignature(Content classInfo) {
476-
classInfo.add(new HtmlTree(HtmlTag.HR));
477505
classInfo.add(new Signatures.TypeSignature(typeElement, this)
478506
.toContent());
479507
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@ public static HtmlId forText(String text, Map<String, Integer> counts) {
462462
return HtmlId.of(count == 0 ? base : base + "-" + count);
463463
}
464464

465+
/**
466+
* Returns an id for text documenting a type parameter of a class or method.
467+
*
468+
* @param paramName the name of the type parameter
469+
* @param owner the enclosing element
470+
*
471+
* @return the id
472+
*/
473+
public HtmlId forTypeParam(String paramName, Element owner) {
474+
if (utils.isExecutableElement(owner)) {
475+
return HtmlId.of(forMember((ExecutableElement) owner).getFirst().name()
476+
+ "-type-param-" + paramName);
477+
}
478+
return HtmlId.of("type-param-" + paramName);
479+
}
480+
465481
/**
466482
* Returns an id for one of the kinds of section in the pages for item group summaries.
467483
*

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ public Content visitTypeVariable(TypeVariable type, HtmlLinkInfo linkInfo) {
162162
Element owner = typevariable.asElement().getEnclosingElement();
163163
if (linkInfo.linkTypeParameters() && utils.isTypeElement(owner)) {
164164
linkInfo.setTypeElement((TypeElement) owner);
165-
Content label = newContent();
166-
label.add(utils.getTypeName(type, false));
167-
linkInfo.label(label).skipPreview(true);
165+
if (linkInfo.getLabel() == null || linkInfo.getLabel().isEmpty()) {
166+
Content label = newContent();
167+
label.add(utils.getTypeName(type, false));
168+
linkInfo.label(label).skipPreview(true);
169+
}
168170
link.add(getClassLink(linkInfo));
169171
} else {
170172
// No need to link method type parameters.
@@ -242,6 +244,11 @@ protected Content getClassLink(HtmlLinkInfo linkInfo) {
242244
boolean isTypeLink = linkInfo.getType() != null &&
243245
utils.isTypeVariable(utils.getComponentType(linkInfo.getType()));
244246
title = getClassToolTip(typeElement, isTypeLink);
247+
if (isTypeLink) {
248+
linkInfo.fragment(m_writer.configuration.htmlIds.forTypeParam(
249+
utils.getTypeName(utils.getComponentType(linkInfo.getType()), false),
250+
typeElement).name());
251+
}
245252
}
246253
Content label = linkInfo.getClassLinkLabel(configuration);
247254
if (linkInfo.getContext() == HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL) {

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template

+16-2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ document.addEventListener("readystatechange", (e) => {
232232
});
233233
document.addEventListener("DOMContentLoaded", function(e) {
234234
setTopMargin();
235+
// Reset animation for type parameter target highlight
236+
document.querySelectorAll("a").forEach((link) => {
237+
link.addEventListener("click", (e) => {
238+
const href = e.currentTarget.getAttribute("href");
239+
if (href && href.startsWith("#") && href.indexOf("type-param-") > -1) {
240+
const target = document.getElementById(decodeURI(href.substring(1)));
241+
if (target) {
242+
target.style.animation = "none";
243+
void target.offsetHeight;
244+
target.style.removeProperty("animation");
245+
}
246+
}
247+
})
248+
});
235249
// Make sure current element is visible in breadcrumb navigation on small displays
236250
const subnav = document.querySelector("ol.sub-nav-list");
237251
if (subnav && subnav.lastElementChild) {
@@ -286,7 +300,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
286300
});
287301
var expanded = false;
288302
var windowWidth;
289-
function collapse() {
303+
function collapse(e) {
290304
if (expanded) {
291305
mainnav.removeAttribute("style");
292306
if (toc) {
@@ -336,7 +350,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
336350
document.querySelectorAll("h1, h2, h3, h4, h5, h6")
337351
.forEach((hdr, idx) => {
338352
// Create anchor links for headers with an associated id attribute
339-
var id = hdr.getAttribute("id") || hdr.parentElement.getAttribute("id")
353+
var id = hdr.parentElement.getAttribute("id") || hdr.getAttribute("id")
340354
|| (hdr.querySelector("a") && hdr.querySelector("a").getAttribute("id"));
341355
if (id) {
342356
var template = document.createElement('template');

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css

+19-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
--search-input-text-color: #000000;
6464
--search-input-placeholder-color: #909090;
6565
/* Highlight color for active search tag target */
66-
--search-tag-highlight-color: #ffff00;
66+
--search-tag-highlight-color: #ffff66;
6767
/* Adjustments for icon and active background colors of copy-to-clipboard buttons */
6868
--copy-icon-brightness: 100%;
6969
--copy-button-background-color-active: rgba(168, 168, 176, 0.3);
@@ -307,7 +307,7 @@ ol.sub-nav-list a.current-selection {
307307
*/
308308
.title {
309309
color:var(--title-color);
310-
margin:10px 0;
310+
margin:10px 0 12px 0;
311311
}
312312
.sub-title {
313313
margin:5px 0 0 0;
@@ -988,6 +988,22 @@ input::placeholder {
988988
.search-tag-result:target {
989989
background-color:var(--search-tag-highlight-color);
990990
}
991+
dd > span:target,
992+
h1 > span:target {
993+
animation: 2.4s ease-out highlight;
994+
}
995+
section.class-description dd > span:target,
996+
section.class-description h1 > span:target {
997+
scroll-margin-top: 20em;
998+
}
999+
@keyframes highlight {
1000+
from {
1001+
background-color: var(--search-tag-highlight-color);
1002+
}
1003+
60% {
1004+
background-color: var(--search-tag-highlight-color);
1005+
}
1006+
}
9911007
details.page-search-details {
9921008
display: inline-block;
9931009
}
@@ -1040,7 +1056,7 @@ span#page-search-link {
10401056
z-index: 5;
10411057
}
10421058
.inherited-list {
1043-
margin: 10px 0 10px 0;
1059+
margin: 10px 0;
10441060
}
10451061
.horizontal-scroll {
10461062
overflow: auto hidden;

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

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -176,7 +176,7 @@ Content linkSeeReferenceOutput(Element holder,
176176
return htmlWriter.getPackageLink(refPackage, labelContent, refFragment);
177177
} else {
178178
// @see is not referencing an included class, module or package. Check for cross-links.
179-
String refModuleName = ch.getReferencedModuleName(refSignature);
179+
String refModuleName = ch.getReferencedModuleName(refSignature);
180180
DocLink elementCrossLink = (refPackage != null) ? htmlWriter.getCrossPackageLink(refPackage) :
181181
(config.extern.isModule(refModuleName))
182182
? htmlWriter.getCrossModuleLink(utils.elementUtils.getModuleElement(refModuleName))
@@ -190,12 +190,28 @@ Content linkSeeReferenceOutput(Element holder,
190190
if (!config.isDocLintReferenceGroupEnabled()) {
191191
reportWarning.accept(
192192
"doclet.link.see.reference_not_found",
193-
new Object[] { refSignature});
193+
new Object[] {refSignature});
194194
}
195195
return htmlWriter.invalidTagOutput(resources.getText("doclet.link.see.reference_invalid"),
196-
Optional.of(labelContent.isEmpty() ? text: labelContent));
196+
Optional.of(labelContent.isEmpty() ? text : labelContent));
197197
}
198198
}
199+
} else if (utils.isTypeParameterElement(ref)) {
200+
// This is a type parameter of a generic class, method or constructor
201+
if (labelContent.isEmpty()) {
202+
labelContent = plainOrCode(isPlain, Text.of(utils.getSimpleName(ref)));
203+
}
204+
if (refMem == null) {
205+
return htmlWriter.getLink(
206+
new HtmlLinkInfo(config, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS, ref.asType())
207+
.label(labelContent));
208+
} else {
209+
// HtmlLinkFactory does not render type parameters of generic methods as links, so instead of
210+
// teaching it how to do it (making the code even more complex) just create the link directly.
211+
return htmlWriter.getLink(new HtmlLinkInfo(config, HtmlLinkInfo.Kind.PLAIN, refClass)
212+
.fragment(config.htmlIds.forTypeParam(ref.getSimpleName().toString(), refMem).name())
213+
.label((labelContent)));
214+
}
199215
} else if (refFragment == null) {
200216
// Must be a class reference since refClass is not null and refFragment is null.
201217
if (labelContent.isEmpty() && refTree != null) {

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, 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
@@ -278,7 +278,9 @@ private Content paramTagOutput(Element element, ParamTree paramTag, String param
278278
body.add(" - ");
279279
List<? extends DocTree> description = ch.getDescription(paramTag);
280280
body.add(htmlWriter.commentTagsToContent(element, description, context.within(paramTag)));
281-
return HtmlTree.DD(body);
281+
return HtmlTree.DD(paramTag.isTypeParameter()
282+
? HtmlTree.SPAN_ID(config.htmlIds.forTypeParam(paramName, element), body)
283+
: body);
282284
}
283285

284286
private record Documentation(ParamTree paramTree, ExecutableElement method) { }

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java

+6
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ public Element getReferencedMember(Element e) {
188188
Utils utils = configuration.utils;
189189
if (e == null) {
190190
return null;
191+
} else if (utils.isTypeParameterElement(e)) {
192+
// Return the enclosing member for type parameters of generic methods or constructors.
193+
Element encl = e.getEnclosingElement();
194+
if (utils.isExecutableElement(encl)) {
195+
return encl;
196+
}
191197
}
192198
return (utils.isExecutableElement(e) || utils.isVariableElement(e)) ? e : null;
193199
}

‎test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -102,7 +102,6 @@ public void test() {
102102

103103
checkOutput("pkg/TestAnnotationType.html", true,
104104
"""
105-
<hr>
106105
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
107106
@Documented
108107
</span><span class="modifiers">public @interface </span><span class="element-name type-n\
@@ -135,7 +134,6 @@ public void test() {
135134

136135
checkOutput("pkg/TestClass.html", true,
137136
"""
138-
<hr>
139137
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
140138
</span><span class="modifiers">public class </span><span class="element-name type-name-label">TestClass</span>
141139
<span class="extends-implements">extends java.lang.Object</span></div>
@@ -212,7 +210,6 @@ public void test() {
212210

213211
checkOutput("pkg/TestEnum.html", true,
214212
"""
215-
<hr>
216213
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
217214
</span><span class="modifiers">public enum </span><span class="element-name type-name-label">TestEnum</span>
218215
<span class="extends-implements">extends java.lang.Enum&lt;<a href="TestEnum.htm\
@@ -233,7 +230,6 @@ public void test() {
233230

234231
checkOutput("pkg/TestError.html", true,
235232
"""
236-
<hr>
237233
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
238234
</span><span class="modifiers">public class </span><span class="element-name type-name-label">TestError</span>
239235
<span class="extends-implements">extends java.lang.Error</span></div>
@@ -244,7 +240,6 @@ public void test() {
244240

245241
checkOutput("pkg/TestException.html", true,
246242
"""
247-
<hr>
248243
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
249244
</span><span class="modifiers">public class </span><span class="element-name type-name-label">TestException</span>
250245
<span class="extends-implements">extends java.lang.Exception</span></div>
@@ -255,7 +250,6 @@ public void test() {
255250

256251
checkOutput("pkg/TestInterface.html", true,
257252
"""
258-
<hr>
259253
<div class="type-signature"><span class="annotations">@Deprecated(forRemoval=true)
260254
</span><span class="modifiers">public class </span><span class="element-name type-name-label">TestInterface</span>
261255
<span class="extends-implements">extends java.lang.Object</span></div>

‎test/langtools/jdk/javadoc/doclet/testDirectedInheritance/TestDirectedInheritance.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2024, 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
@@ -154,8 +154,8 @@ public interface E1 extends I1, I2 {
154154
<div class="block">I2: main description</div>
155155
""", """
156156
<dt>Type Parameters:</dt>
157-
<dd><code>E</code> - I2: first type parameter</dd>
158-
<dd><code>F</code> - I2: second type parameter</dd>
157+
<dd><span id="m(E)-type-param-E"><code>E</code> - I2: first type parameter</span></dd>
158+
<dd><span id="m(E)-type-param-F"><code>F</code> - I2: second type parameter</span></dd>
159159
<dt>Parameters:</dt>
160160
<dd><code>eObj</code> - I2: parameter</dd>
161161
<dt>Returns:</dt>

‎test/langtools/jdk/javadoc/doclet/testErasure/TestErasure.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class X { }
199199
<div class="col-first even-row-color"><code>&nbsp;</code></div>
200200
<div class="col-constructor-name even-row-color"><code>\
201201
<a href="#%3Cinit%3E(T)" class="member-name-link">Foo</a>\
202-
<wbr>(<a href="Foo.html" title="type parameter in Foo">T</a>&nbsp;arg)</code></div>
202+
<wbr>(<a href="#type-param-T" title="type parameter in Foo">T</a>&nbsp;arg)</code></div>
203203
<div class="col-last even-row-color">&nbsp;</div>
204204
<div class="col-first odd-row-color"><code>&nbsp;&lt;T extends X&gt;<br></code></div>
205205
<div class="col-constructor-name odd-row-color"><code>\
@@ -227,10 +227,10 @@ class X { }
227227
// methods
228228
checkOutput("Foo.html", true, """
229229
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 \
230-
method-summary-table-tab3"><code>abstract <a href="Foo.html" title="type parameter in Foo">T</a></code></div>
230+
method-summary-table-tab3"><code>abstract <a href="#type-param-T" title="type parameter in Foo">T</a></code></div>
231231
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 \
232232
method-summary-table-tab3"><code><a href="#m(T)" class="member-name-link">m</a>\
233-
<wbr>(<a href="Foo.html" title="type parameter in Foo">T</a>&nbsp;arg)</code></div>
233+
<wbr>(<a href="#type-param-T" title="type parameter in Foo">T</a>&nbsp;arg)</code></div>
234234
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 \
235235
method-summary-table-tab3">&nbsp;</div>
236236
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 \
@@ -385,4 +385,4 @@ class Y { }
385385
<div class="col-second odd-row-color constructor constructor-tab1">Test Feature</div>
386386
<div class="col-last odd-row-color constructor constructor-tab1"></div>""");
387387
}
388-
}
388+
}

‎test/langtools/jdk/javadoc/doclet/testGenericMethodLinkTaglet/TestGenericMethodLinkTaglet.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, 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,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8188248
26+
* @bug 8188248 8313931
2727
* @summary NullPointerException on generic methods
2828
* @library /tools/lib ../../lib
2929
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -67,7 +67,7 @@ public void test(Path base) throws Exception {
6767

6868
checkOutput("pkg/A.html", true,
6969
"""
70-
<a href="A.html" title="class in pkg"><code>A</code></a>""");
70+
param <a href="#m1(T)-type-param-T"><code>T</code></a>""");
7171
}
7272

7373
void createTestClass(Path srcDir) throws Exception {

‎test/langtools/jdk/javadoc/doclet/testHref/TestHref.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -75,7 +75,8 @@ public void test() {
7575

7676
checkOutput("pkg/C4.html", true,
7777
//Header does not link to the page itself.
78-
"Class C4&lt;E extends C4&lt;E&gt;&gt;</h1>",
78+
"""
79+
Class C4&lt;<span id="type-param-E">E extends C4&lt;E&gt;</span>&gt;</h1>""",
7980
//Signature does not link to the page itself.
8081
"""
8182
<span class="modifiers">public abstract class </span><span class="element-name type-name\

‎test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -99,12 +99,12 @@ public void test() {
9999
<dt>Specified by:</dt>
100100
<dd><code><a href="Interface.html#method()">method</a></code>&nbsp;in interface&\
101101
nbsp;<code><a href="Interface.html" title="interface in pkg">Interface</a>&lt;<a\
102-
href="Child.html" title="type parameter in Child">CE</a>&gt;</code></dd>""",
102+
href="#type-param-CE" title="type parameter in Child">CE</a>&gt;</code></dd>""",
103103
//Make sure "Overrides" has substituted type parameters.
104104
"""
105105
<dt>Overrides:</dt>
106106
<dd><code><a href="Parent.html#method()">method</a></code>&nbsp;in class&nbsp;<c\
107-
ode><a href="Parent.html" title="class in pkg">Parent</a>&lt;<a href="Child.html\
107+
ode><a href="Parent.html" title="class in pkg">Parent</a>&lt;<a href="#type-param-CE\
108108
" title="type parameter in Child">CE</a>&gt;</code></dd>""");
109109

110110
checkOutput("pkg/Parent.html", true,
@@ -190,7 +190,7 @@ public void test1() {
190190
<dt>Overrides:</dt>
191191
<dd><code><a href="GrandParent.html#method1()">method1</a></code>&nbsp;in class&\
192192
nbsp;<code><a href="GrandParent.html" title="class in pkg1">GrandParent</a>&lt;<\
193-
a href="Child.html" title="type parameter in Child">CE</a>&gt;</code>""");
193+
a href="#type-param-CE" title="type parameter in Child">CE</a>&gt;</code>""");
194194
}
195195

196196
@Test
@@ -209,17 +209,17 @@ public void test2() {
209209
erface in pkg2">Spliterator</a></h3>
210210
<code><a href="Spliterator.OfDouble.html" title="interface in pkg2">Spliterator.\
211211
OfDouble</a>, <a href="Spliterator.OfInt.html" title="interface in pkg2">Spliter\
212-
ator.OfInt</a>&lt;<a href="Spliterator.OfInt.html" title="type parameter in Spli\
212+
ator.OfInt</a>&lt;<a href="Spliterator.OfInt.html#type-param-Integer" title="type parameter in Spli\
213213
terator.OfInt">Integer</a>&gt;, <a href="Spliterator.OfPrimitive.html" title="in\
214214
terface in pkg2">Spliterator.OfPrimitive</a>&lt;<a href="Spliterator.OfPrimitive\
215-
.html" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><a href="Spl\
216-
iterator.OfPrimitive.html" title="type parameter in Spliterator.OfPrimitive">T_C\
217-
ONS</a>,<wbr><a href="Spliterator.OfPrimitive.html" title="type parameter in Spl\
215+
.html#type-param-T" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><a href="Spl\
216+
iterator.OfPrimitive.html#type-param-T_CONS" title="type parameter in Spliterator.OfPrimitive">T_C\
217+
ONS</a>,<wbr><a href="Spliterator.OfPrimitive.html#type-param-T_SPLITR" title="type parameter in Spl\
218218
iterator.OfPrimitive">T_SPLITR</a> extends <a href="Spliterator.OfPrimitive.html\
219219
" title="interface in pkg2">Spliterator.OfPrimitive</a>&lt;<a href="Spliterator.\
220-
OfPrimitive.html" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><\
221-
a href="Spliterator.OfPrimitive.html" title="type parameter in Spliterator.OfPri\
222-
mitive">T_CONS</a>,<wbr><a href="Spliterator.OfPrimitive.html" title="type param\
220+
OfPrimitive.html#type-param-T" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><\
221+
a href="Spliterator.OfPrimitive.html#type-param-T_CONS" title="type parameter in Spliterator.OfPri\
222+
mitive">T_CONS</a>,<wbr><a href="Spliterator.OfPrimitive.html#type-param-T_SPLITR" title="type param\
223223
eter in Spliterator.OfPrimitive">T_SPLITR</a>&gt;&gt;</code>""");
224224
checkOutput("pkg2/Spliterator.html", true,
225225
"""
@@ -236,21 +236,21 @@ public void test2() {
236236
<div class="col-first odd-row-color"><code>static interface&nbsp;</code></div>
237237
<div class="col-second odd-row-color"><code><a href="Spliterator.OfInt.html" cla\
238238
ss="type-name-link" title="interface in pkg2">Spliterator.OfInt</a>&lt;<a href="\
239-
Spliterator.OfInt.html" title="type parameter in Spliterator.OfInt">Integer</a>&\
239+
Spliterator.OfInt.html#type-param-Integer" title="type parameter in Spliterator.OfInt">Integer</a>&\
240240
gt;</code></div>
241241
<div class="col-last odd-row-color">&nbsp;</div>
242242
<div class="col-first even-row-color"><code>static interface&nbsp;</code></div>
243243
<div class="col-second even-row-color"><code><a href="Spliterator.OfPrimitive.ht\
244244
ml" class="type-name-link" title="interface in pkg2">Spliterator.OfPrimitive</a>\
245-
&lt;<a href="Spliterator.OfPrimitive.html" title="type parameter in Spliterator.\
246-
OfPrimitive">T</a>,<wbr><a href="Spliterator.OfPrimitive.html" title="type param\
245+
&lt;<a href="Spliterator.OfPrimitive.html#type-param-T" title="type parameter in Spliterator.\
246+
OfPrimitive">T</a>,<wbr><a href="Spliterator.OfPrimitive.html#type-param-T_CONS" title="type param\
247247
eter in Spliterator.OfPrimitive">T_CONS</a>,<wbr><a href="Spliterator.OfPrimitiv\
248-
e.html" title="type parameter in Spliterator.OfPrimitive">T_SPLITR</a> extends <\
248+
e.html#type-param-T_SPLITR" title="type parameter in Spliterator.OfPrimitive">T_SPLITR</a> extends <\
249249
a href="Spliterator.OfPrimitive.html" title="interface in pkg2">Spliterator.OfPr\
250-
imitive</a>&lt;<a href="Spliterator.OfPrimitive.html" title="type parameter in S\
251-
pliterator.OfPrimitive">T</a>,<wbr><a href="Spliterator.OfPrimitive.html" title=\
250+
imitive</a>&lt;<a href="Spliterator.OfPrimitive.html#type-param-T" title="type parameter in S\
251+
pliterator.OfPrimitive">T</a>,<wbr><a href="Spliterator.OfPrimitive.html#type-param-T_CONS" title=\
252252
"type parameter in Spliterator.OfPrimitive">T_CONS</a>,<wbr><a href="Spliterator\
253-
.OfPrimitive.html" title="type parameter in Spliterator.OfPrimitive">T_SPLITR</a\
253+
.OfPrimitive.html#type-param-T_SPLITR" title="type parameter in Spliterator.OfPrimitive">T_SPLITR</a\
254254
>&gt;&gt;</code></div>
255255
<div class="col-last even-row-color">&nbsp;</div>
256256
</div>""");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2024, 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 8313931
27+
* @summary Javadoc: links to type parameters actually generate links to classes
28+
* @library /tools/lib ../../lib
29+
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30+
* @build toolbox.ToolBox javadoc.tester.*
31+
* @run main TestLinkTagletTypeParam
32+
*/
33+
34+
import javadoc.tester.JavadocTester;
35+
import toolbox.ToolBox;
36+
37+
import java.io.IOException;
38+
import java.nio.file.Path;
39+
40+
public class TestLinkTagletTypeParam extends JavadocTester {
41+
42+
public static void main(String... args) throws Exception {
43+
var tester = new TestLinkTagletTypeParam();
44+
tester.runTests();
45+
}
46+
47+
ToolBox tb = new ToolBox();
48+
49+
@JavadocTester.Test
50+
public void testClassTypeParameterLink(Path base) throws IOException {
51+
Path src = base.resolve("src");
52+
53+
tb.writeJavaFiles(src,
54+
"""
55+
/**
56+
* Link to {@link F}.
57+
*
58+
* @param <F> the first type param
59+
* @param <APND> an Appendable
60+
*
61+
* @see APND the second type parameter
62+
*/
63+
public class Test<F, APND extends Appendable> {
64+
private Test() {}
65+
}
66+
""");
67+
68+
javadoc("-Xdoclint:none",
69+
"-d", base.resolve("api").toString(),
70+
"-sourcepath", src.toString(),
71+
src.resolve("Test.java").toString());
72+
checkExit(JavadocTester.Exit.OK);
73+
74+
checkOrder("Test.html",
75+
"""
76+
<dt>Type Parameters:</dt>
77+
<dd><span id="type-param-F"><code>F</code> - the first type param</span></dd>
78+
<dd><span id="type-param-APND"><code>APND</code> - an Appendable</span></dd>""",
79+
"""
80+
Link to <a href="#type-param-F" title="type parameter in Test"><code>F</code></a>.""",
81+
"""
82+
<dt>See Also:</dt>
83+
<dd>
84+
<ul class="tag-list">
85+
<li><a href="#type-param-APND" title="type parameter in Test">the second type parameter</a></li>
86+
</ul>""");
87+
}
88+
89+
@JavadocTester.Test
90+
public void testMethodTypeParameterLink(Path base) throws IOException {
91+
Path src = base.resolve("src");
92+
93+
tb.writeJavaFiles(src,
94+
"""
95+
/**
96+
* Class comment.
97+
*/
98+
public class Test {
99+
/**
100+
* Link to {@link T} and {@linkplain T link with label}.
101+
*
102+
* @param <T> the T
103+
* @param appendable the appendable
104+
*/
105+
public <T extends Appendable> T append(final T appendable) {
106+
return appendable;
107+
}
108+
}
109+
""");
110+
111+
javadoc("-Xdoclint:reference",
112+
"-d", base.resolve("api").toString(),
113+
"-sourcepath", src.toString(),
114+
src.resolve("Test.java").toString());
115+
116+
checkOutput(JavadocTester.Output.OUT, true,
117+
"");
118+
119+
checkOutput("Test.html", true,
120+
"""
121+
Link to <a href="#append(T)-type-param-T"><code>T</code></a> and <a href="#appe\
122+
nd(T)-type-param-T">link with label</a>.""");
123+
}
124+
}

‎test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2024, 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
@@ -120,8 +120,8 @@ interface in pkg">BaseInterface</a></code></dd>
120120
checkOutput("pkg2/DocumentedNonGenericChild.html", true,
121121
"""
122122
<section class="class-description" id="class-description">
123-
<div class="horizontal-scroll">
124123
<hr>
124+
<div class="horizontal-scroll">
125125
<div class="type-signature"><span class="modifiers">public abstract class </span\
126126
><span class="element-name type-name-label">DocumentedNonGenericChild</span>
127127
<span class="extends-implements">extends java.lang.Object</span></div>

‎test/langtools/jdk/javadoc/doclet/testModules/TestModules.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ void checkLinkSource(boolean includePrivate) {
13601360
checkOutput("moduleA/testpkgmdlA/TestClassInModuleA.html", true,
13611361
"""
13621362
<section class="class-description" id="class-description">
1363-
<div class="horizontal-scroll">
13641363
<hr>
1364+
<div class="horizontal-scroll">
13651365
<div class="type-signature"><span class="modifiers">public class </span><span cl\
13661366
ass="element-name"><a href="../../src-html/moduleA/testpkgmdlA/TestClassInModule\
13671367
A.html#line-25">TestClassInModuleA</a></span>

‎test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -117,7 +117,7 @@ void checkTypeParameters() {
117117
// Check class type parameters section.
118118
"""
119119
<dt>Type Parameters:</dt>
120-
<dd><code>E</code> - the type parameter for this class.""",
120+
<dd><span id="type-param-E"><code>E</code> - the type parameter for this class.</span></dd>""",
121121
// Type parameters in @see/@link
122122
"""
123123
<dl class="notes">
@@ -130,12 +130,14 @@ void checkTypeParameters() {
130130
</dl>""",
131131
// Method that uses class type parameter.
132132
"""
133-
(<a href="TypeParameters.html" title="type parameter in TypeParameters">E</a>&nbsp;param)""",
133+
(<a href="#type-param-E" title="type parameter in TypeParameters">E</a>&nbsp;param)""",
134134
// Method type parameter section.
135135
"""
136136
<dt>Type Parameters:</dt>
137-
<dd><code>T</code> - This is the first type parameter.</dd>
138-
<dd><code>V</code> - This is the second type parameter.""",
137+
<dd><span id="methodThatHasTypeParameters(T,V)-type-param-T"><code>T</code> - Th\
138+
is is the first type parameter.</span></dd>
139+
<dd><span id="methodThatHasTypeParameters(T,V)-type-param-V"><code>V</code> - Th\
140+
is is the second type parameter.</span></dd>""",
139141
// Signature of method with type parameters
140142
"""
141143
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span c\
@@ -147,18 +149,18 @@ void checkTypeParameters() {
147149
// Method that returns TypeParameters
148150
"""
149151
<div class="col-first even-row-color method-summary-table method-summary-table-t\
150-
ab2 method-summary-table-tab4"><code><a href="TypeParameters.html" title="type p\
152+
ab2 method-summary-table-tab4"><code><a href="#type-param-E" title="type p\
151153
arameter in TypeParameters">E</a>[]</code></div>
152154
<div class="col-second even-row-color method-summary-table method-summary-table-\
153155
tab2 method-summary-table-tab4"><code><a href="#methodThatReturnsTypeParameterA(\
154156
E%5B%5D)" class="member-name-link">methodThatReturnsTypeParameterA</a><wbr>(<a h\
155-
ref="TypeParameters.html" title="type parameter in TypeParameters">E</a>[]&nbsp;\
157+
ref="#type-param-E" title="type parameter in TypeParameters">E</a>[]&nbsp;\
156158
e)</code>""",
157159
"""
158160
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span c\
159-
lass="return-type"><a href="TypeParameters.html" title="type parameter in TypePa\
161+
lass="return-type"><a href="#type-param-E" title="type parameter in TypePa\
160162
rameters">E</a>[]</span>&nbsp;<span class="element-name">methodThatReturnsTypePa\
161-
rameterA</span><wbr><span class="parameters">(<a href="TypeParameters.html" titl\
163+
rameterA</span><wbr><span class="parameters">(<a href="#type-param-E" titl\
162164
e="type parameter in TypeParameters">E</a>[]&nbsp;e)</span></div>
163165
""",
164166
"""
@@ -176,7 +178,7 @@ void checkTypeParameters() {
176178
"""
177179
<div class="col-first odd-row-color method-summary-table method-summary-table-ta\
178180
b2 method-summary-table-tab4"><code>&lt;X extends java.lang.Throwable&gt;<br><a \
179-
href="TypeParameters.html" title="type parameter in TypeParameters">E</a></code>\
181+
href="#type-param-E" title="type parameter in TypeParameters">E</a></code>\
180182
</div>
181183
<div class="col-second odd-row-color method-summary-table method-summary-t\
182184
able-tab2 method-summary-table-tab4"><code><a href="#orElseThrow(java.util.funct\

‎test/langtools/jdk/javadoc/doclet/testParamTaglet/TestParamTaglet.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -79,7 +79,7 @@ public void test() {
7979
</dl>""",
8080
"""
8181
<dt>Type Parameters:</dt>
82-
<dd><code>T2</code> - type 2</dd>
82+
<dd><span id="genericMethod(T1,T2,T3)-type-param-T2"><code>T2</code> - type 2</span></dd>
8383
<dt>Parameters:</dt>
8484
<dd><code>t1</code> - param 1</dd>
8585
<dd><code>t3</code> - param 3</dd>
@@ -92,7 +92,7 @@ public void test() {
9292
checkOutput("pkg/C.Nested.html", true,
9393
"""
9494
<dt>Type Parameters:</dt>
95-
<dd><code>T1</code> - type 1</dd>
95+
<dd><span id="type-param-T1"><code>T1</code> - type 1</span></dd>
9696
</dl>""");
9797
}
9898
}

‎test/langtools/jdk/javadoc/doclet/testProperty/TestProperty.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2024, 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
@@ -110,7 +110,7 @@ class in pkg">ObjectProperty</a><wbr>&lt;<a href="MyObj.html" title="class in pk
110110
"""
111111
<div class="member-signature"><span class="modifiers">public final</span>&nbsp;<\
112112
span class="return-type"><a href="ObjectProperty.html" title="class in pkg">Obje\
113-
ctProperty</a>&lt;java.util.List&lt;<a href="MyClassT.html" title="type paramete\
113+
ctProperty</a>&lt;java.util.List&lt;<a href="#type-param-T" title="type paramete\
114114
r in MyClassT">T</a>&gt;&gt;</span>&nbsp;<span class="element-name">listProperty</span><\
115115
/div>
116116
<div class="block">This is an Object property where the Object is a single <code>List&lt;T&gt;</code>.</div>

‎test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public record R<T>(int r1) { }""");
175175
"""
176176
<dl class="notes">
177177
<dt>Type Parameters:</dt>
178-
<dd><code>T</code> - This is a type parameter.</dd>
178+
<dd><span id="type-param-T"><code>T</code> - This is a type parameter.</span></dd>
179179
<dt>Record Components:</dt>
180180
<dd><code><span id="param-r1">r1</span></code> - This is a component.</dd>
181181
</dl>""",

‎test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, 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
@@ -219,6 +219,7 @@ public void test2() {
219219
"""
220220
<a href="pkg2/Fields.html" title="class in pkg2">Fields</a>[] singleArray""",
221221
"""
222-
java.lang.Class&lt;<a href="pkg2/Fields.html" title="type parameter in Fields">E</a>&gt; someClass""");
222+
java.lang.Class&lt;<a href="pkg2/Fields.html#type-param-E" title="type paramete\
223+
r in Fields">E</a>&gt; someClass""");
223224
}
224225
}

‎test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2024, 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
@@ -83,7 +83,7 @@ public interface C {
8383
"""
8484
<dl class="notes">
8585
<dt>Type Parameters:</dt>
86-
<dd><code>T</code> - the throwable</dd>
86+
<dd><span id="m()-type-param-T"><code>T</code> - the throwable</span></dd>
8787
<dt>Throws:</dt>
8888
<dd><code>T</code> - if a specific error occurs</dd>
8989
<dd><code>java.lang.Exception</code> - if an exception occurs</dd>

‎test/langtools/jdk/javadoc/doclet/testTypeParams/TestTypeParameters.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 4927167 4974929 6381729 7010344 8025633 8081854 8182765 8187288 8261976
26+
* @bug 4927167 4974929 6381729 7010344 8025633 8081854 8182765 8187288 8261976 8313931
2727
* @summary When the type parameters are more than 10 characters in length,
2828
* make sure there is a line break between type params and return type
2929
* in member summary. Also, test for type parameter links in package-summary and
@@ -110,10 +110,22 @@ public void test3() {
110110
<div class="col-first even-row-color"><code>&nbsp;&lt;T extends java.lang.Runnable&gt;<br></code></div>
111111
<div class="col-constructor-name even-row-color"><code>\
112112
<a href="#%3Cinit%3E()" class="member-name-link">CtorTypeParam</a>()</code></div>
113-
<div class="col-last even-row-color">&nbsp;</div>""",
113+
<div class="col-last even-row-color">
114+
<div class="block">Generic constructor.</div>""",
114115
"""
115116
<div class="member-signature"><span class="modifiers">public</span>\
116117
&nbsp;<span class="type-parameters">&lt;T extends java.lang.Runnable&gt;</span>\
117-
&nbsp;<span class="element-name">CtorTypeParam</span>()</div>""");
118+
&nbsp;<span class="element-name">CtorTypeParam</span>()</div>""",
119+
"""
120+
<a href="#%3Cinit%3E()-type-param-T"><code>T</code></a>""",
121+
"""
122+
<dt>Type Parameters:</dt>
123+
<dd><span id="&lt;init&gt;()-type-param-T"><code>T</code> - the type parameter</span></dd>""",
124+
"""
125+
<dt>See Also:</dt>
126+
<dd>
127+
<ul class="tag-list">
128+
<li><a href="#%3Cinit%3E()-type-param-T">link to type parameter</a></li>
129+
</ul>""");
118130
}
119131
}

‎test/langtools/jdk/javadoc/doclet/testTypeParams/pkg/CtorTypeParam.java

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
package pkg;
2525

2626
public class CtorTypeParam {
27+
/**
28+
* Generic constructor. {@link T}
29+
*
30+
* @param <T> the type parameter
31+
* @see T link to type parameter
32+
*/
2733
public <T extends Runnable> CtorTypeParam() {
2834
}
2935
}

‎test/langtools/jdk/javadoc/doclet/testUnicode/TestUnicode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, 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
@@ -101,7 +101,7 @@ public class Code<##> {
101101
"""
102102
<dl class="notes">
103103
<dt>Type Parameters:</dt>
104-
<dd><code>##</code> - the ##</dd>
104+
<dd><span id="type-param-##"><code>##</code> - the ##</span></dd>
105105
</dl>
106106
""".replaceAll("##", chineseElephant),
107107
"""

0 commit comments

Comments
 (0)
Please sign in to comment.