On Tue, 18 Nov 2025 13:28:37 GMT, Hannes Wallnöfer <[email protected]> wrote:
> Please review a change to make unqualified anchor references such as `{@link
> ##anchor link}` work everywhere. Previously, such links only worked in class
> pages. The fix consists in attributing the correct Element in
> `JavacTrees::attributeDocReference` for references declared in API elements,
> and setting it to `null` for references defined in `doc-files` to make them
> work as local links.
>
> Because of unattributed `doc-files` references, we also have to exclude such
> links from the reference check in DocLint. This is fine because local
> references always have a target element, and we do not check the anchor
> anyway.
The tests look very good.
src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java line 422:
> 420: case COMPILATION_UNIT ->
> 421: // Treat unqualified reference in legacy
> package.html as package reference.
> 422: // Unqualified references in doc-fiiles only
> need to work locally, so null is fine.
Suggestion:
// Unqualified references in doc-files only need to
work locally, so null is fine.
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java
line 166:
> 164: // Unqualified local anchor link
> 165: return
> htmlWriter.links.createLink(HtmlId.of(refFragment), labelContent);
> 166: }
Why do we need a new if here? Does this not fall into the `else if (refFragment
== null) {` block somehow?
-------------
PR Review: https://git.openjdk.org/jdk/pull/28372#pullrequestreview-3506058261
PR Review Comment: https://git.openjdk.org/jdk/pull/28372#discussion_r2560783266
PR Review Comment: https://git.openjdk.org/jdk/pull/28372#discussion_r2560805106