Skip to content

8372055: Fragment link tag does not work in package info#28372

Closed
hns wants to merge 4 commits intoopenjdk:masterfrom
hns:JDK-8372055
Closed

8372055: Fragment link tag does not work in package info#28372
hns wants to merge 4 commits intoopenjdk:masterfrom
hns:JDK-8372055

Conversation

@hns
Copy link
Member

@hns hns commented Nov 18, 2025

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8372055: Fragment link tag does not work in package info (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28372/head:pull/28372
$ git checkout pull/28372

Update a local copy of the PR:
$ git checkout pull/28372
$ git pull https://git.openjdk.org/jdk.git pull/28372/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28372

View PR using the GUI difftool:
$ git pr show -t 28372

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28372.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2025

👋 Welcome back hannesw! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 18, 2025

@hns This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8372055: Fragment link tag does not work in package info

Reviewed-by: liach

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 136 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added javadoc javadoc-dev@openjdk.org compiler compiler-dev@openjdk.org labels Nov 18, 2025
@openjdk
Copy link

openjdk bot commented Nov 18, 2025

@hns The following labels will be automatically applied to this pull request:

  • compiler
  • javadoc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@hns hns marked this pull request as ready for review November 21, 2025 13:31
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 21, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 21, 2025

Webrevs

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests look very good.

case MODULE -> env.toplevel.modle;
case COMPILATION_UNIT ->
// Treat unqualified reference in legacy package.html as package reference.
// Unqualified references in doc-fiiles only need to work locally, so null is fine.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Unqualified references in doc-fiiles only need to work locally, so null is fine.
// Unqualified references in doc-files only need to work locally, so null is fine.

if (ref == null && refSignature.startsWith("##")) {
// Unqualified local anchor link
return htmlWriter.links.createLink(HtmlId.of(refFragment), labelContent);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a new if here? Does this not fall into the else if (refFragment == null) { block somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refFragment is not null here, ref is, which is the referenced element. This is necessary for unqualified hash fragment links in doc-files, where the referenced element is set to null in JavacTrees. We know that local links in doc-files will never be used outside of the doc-file itself (for example in summary or index pages), so we can always create a simple local hash fragment link.

I've updated the comment to say that this is for doc-files.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 26, 2025
@hns
Copy link
Member Author

hns commented Nov 26, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Nov 26, 2025

Going to push as commit 85d4f55.
Since your change was applied there have been 137 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 26, 2025
@openjdk openjdk bot closed this Nov 26, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 26, 2025
@openjdk
Copy link

openjdk bot commented Nov 26, 2025

@hns Pushed as commit 85d4f55.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org integrated Pull request has been integrated javadoc javadoc-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants