Skip to content

8177100: APIs duplicated in JavaDoc #25123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from

Conversation

nizarbenalla
Copy link
Member

@nizarbenalla nizarbenalla commented May 8, 2025

Please review this patch to fix a bug where a method can be documented multiple times
Consider these 4 classes

                    A       (interface)
                   / \
                  /   \
(abstract class)  C     B   ( interface)
                  \   /
                   \ /
                    D       (class)

Where A declares testA(), C implements it public final void testA(), B extends A but does not override it, D extends C and implements B

In the generated javadoc, testA() is documented twice.

Screenshot 2025-05-08 at 15 51 19

After the patch, testA() is only documented once:

Screenshot 2025-05-08 at 15 52 16


Progress

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

Issue

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25123

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 8, 2025

👋 Welcome back nbenalla! 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 May 8, 2025

@nizarbenalla 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:

8177100: APIs duplicated in JavaDoc

Reviewed-by: liach, hannesw

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 29 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 the rfr Pull request is ready for review label May 8, 2025
@openjdk
Copy link

openjdk bot commented May 8, 2025

@nizarbenalla The following label will be automatically applied to this pull request:

  • javadoc

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

@mlbridge
Copy link

mlbridge bot commented May 8, 2025

@@ -689,10 +689,15 @@ private boolean allowInheritedMethod(ExecutableElement inheritedMethod,
if (inInterface) {
List<ExecutableElement> list = overriddenByTable.get(inheritedMethod);
if (list != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Can't we change this to if (list != null && !list.isEmpty) return false;?

Comments can be to update the overall block comment to indicate that there is no contention - when a method overrides multiple superinterfaces' methods, including when it is final from superclasses, the superclass method always prevails due to method resolution rules in Java. All interface methods have low resolution priority.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this simplification works just fine.

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.

Looks good, thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 9, 2025
@hns
Copy link
Member

hns commented May 9, 2025

I'm not sure about this. @nizarbenalla have you tested whether this changes the output for JDK docs?

@hns
Copy link
Member

hns commented May 9, 2025

There's a problem with character encoding in this patch, please do not integrate:

 /Users/runner/work/jdk/jdk/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java:681: error: unmappable character (0x80) for encoding ascii
        // Multiple-Inheritance: No Contention. In Java???s method resolution,

@liach
Copy link
Member

liach commented May 9, 2025

/reviewers 2 committer

@openjdk
Copy link

openjdk bot commented May 9, 2025

@liach
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Committer).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 9, 2025
@hns
Copy link
Member

hns commented May 9, 2025

As I suspected, this removes methods from the "Methods declared in interface XY" sections. For example, in the java.lang.StringBuilder doc page section for methods declared in java.lang.CharSequence it removes all methods except isEmpty(). So this is not the right place to fix this. I think we should only eliminate these overridden methods when they are to be documented in the subclass (when the declaring class is undocumented).

@nizarbenalla
Copy link
Member Author

Hannes suggested in offline discussion where the check can be instead of the old approach.
I have checked that there is no change in the current JDK doc build after applying this patch.

Thanks for catching this oversight during the review.

@nizarbenalla
Copy link
Member Author

nizarbenalla commented May 12, 2025

Please don't review this yet, I plan on pushing an other update.

@nizarbenalla
Copy link
Member Author

I've updated the test as the name was not accurate, and simplified the code in VisibleMemberTable

@nizarbenalla nizarbenalla requested a review from liach May 15, 2025 13:00
@hns
Copy link
Member

hns commented May 28, 2025

I have to apologize for my previous review. When I noticed that JDK documentation had changed, my knee-jerk reaction was to assume that the change was wrong. But it is indeed the current documentation that is wrong.

For example in StringBuilder, the methods overridden in the hidden AbstractStringBuilder class should not be shown as declared in CharSequence as they are documented as local methods in StringBuilder (even though they are implemented in a hidden superclass).

Similarly (but without the hidden superclass), the equals and hashCode methods in HashMap should not be documented as declared in interface Map, but only in AbstractMap where they override the default implementation.

So your first solution (in the simplified form) was actually correct after all.

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.

Looks identical to the initial version.

@hns
Copy link
Member

hns commented Jun 10, 2025

Looks identical to the initial version.

@liach I realized the first version was right after all (see my comment above). We should not document a method as inherited from some interface when it is implemented in the local class or some superclass. So this gets rid of duplicate inherited methods, such as equals(Object) in HashMap appearing as inherited both from class AbstractMap and interface Map.

"sb");
checkExit(Exit.OK);

checkOutput("sb/U.html", false,
Copy link
Member

@hns hns Jun 10, 2025

Choose a reason for hiding this comment

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

Could you add a positive check to this test and testHashMapInheritance that the method is documented as expected (as local method in this test, and as inherited from the public abstract class in testHashMapInheritance), and that the method details has a "Specified by: ..." entry pointing to the interface method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the test to add a positive check. Tests are currently running in CI.
If the update look trivial enough, could you set the reviewer count back to 1?

@nizarbenalla
Copy link
Member Author

Passes tier 1-3.

@nizarbenalla nizarbenalla requested a review from hns June 26, 2025 09:11
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">V</span>()</div>
</div>
""");
Copy link
Member

Choose a reason for hiding this comment

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

That's the doc for the constructor. I was looking for method testJ inherited from abstract class PubJ.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe testJ does not have it's own doc in V.html. It only appears in the "methods inherited from class J" section

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what should be tested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in a34c4d5.

Copy link
Member

@hns hns left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

And sorry for being nit-picky about the tests, but it's better to have all details covered.

@nizarbenalla
Copy link
Member Author

nizarbenalla commented Jul 4, 2025

Thank you for the reviews Hannes and Chen.

I will integrate once CI jobs are completed on all platforms. Better to be careful.

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 test update looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 4, 2025
@nizarbenalla
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 4, 2025

Going to push as commit f2d2eef.
Since your change was applied there have been 31 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 Jul 4, 2025
@openjdk openjdk bot closed this Jul 4, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 4, 2025
@openjdk
Copy link

openjdk bot commented Jul 4, 2025

@nizarbenalla Pushed as commit f2d2eef.

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

@nizarbenalla nizarbenalla deleted the duplicate-APIs branch July 4, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated javadoc [email protected]
Development

Successfully merging this pull request may close these issues.

3 participants