Skip to content

Conversation

@nizarbenalla
Copy link
Member

@nizarbenalla nizarbenalla commented Jan 5, 2025

Please review this PR to clarify the documentation of Elements.overrides through an @apiNote, this PR is essentially a doc-only change. This PR supersedes #22244.

TIA.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8356164 to be approved
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8174840: Elements.overrides does not check the return type of the methods (Bug - P4)
  • JDK-8356164: Elements.overrides does not check the return type of the methods (CSR)

Reviewers

Contributors

  • Pavel Rappo <prappo@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22920

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 5, 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 Jan 5, 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:

8174840: Elements.overrides does not check the return type of the methods

Co-authored-by: Pavel Rappo <prappo@openjdk.org>
Reviewed-by: liach, darcy

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 730 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
Copy link

openjdk bot commented Jan 5, 2025

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

  • compiler

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.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jan 5, 2025
Comment on lines 784 to 785
* on thrown types, return types and those constraints on method modifiers not directly
* bound to the overriding relation as such.
Copy link
Member

@liach liach Jan 6, 2025

Choose a reason for hiding this comment

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

Suggested change
* on thrown types, return types and those constraints on method modifiers not directly
* bound to the overriding relation as such.
* on exception types, return types, and method modifiers do not affect
* the overriding relation.

The original wording has grammatical mistake and makes no sense.

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 don't agree that it makes no sense but I find this wording simpler, so I'll use it instead.

Copy link
Member

Choose a reason for hiding this comment

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

I would strongly recommend to wait for @jddarcy to review that.

Copy link
Member

Choose a reason for hiding this comment

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

The basic situation is that the "overrides" relation a develop has in mind may not be the same as the more restricted "overrides" relation defined in JLS. However, we don't necessarily want to require the extra checks to be omitted and don't necessarily wan to forbid the extra checks from being done.

The current wording doesn't accomplish this.

@nizarbenalla nizarbenalla marked this pull request as ready for review January 6, 2025 12:35
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 6, 2025
@mlbridge
Copy link

mlbridge bot commented Jan 6, 2025

Webrevs

@nizarbenalla
Copy link
Member Author

/contributor add prappo

@openjdk
Copy link

openjdk bot commented Jan 6, 2025

@nizarbenalla
Contributor Pavel Rappo <prappo@openjdk.org> successfully added.

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Is the beginning copyright year 2023 correct?

Copy link
Member

@pavelrappo pavelrappo Jan 6, 2025

Choose a reason for hiding this comment

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

Yes, it is. The patch attached to the JBS issue is dated 2023. That patch is used in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the verification.

var tm = mIn(t);
if (!elements.overrides(tm, sm, t))
messager.printError(String.format(
"%s does not override %s from %s", tm, sm, t.getQualifiedName()));
Copy link
Member

Choose a reason for hiding this comment

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

This message implies sm is from t, which is not the case. Consider improving the failure message.

Copy link
Member

Choose a reason for hiding this comment

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

This uses the wording from JLS 8.4.8.1 (emphasis mine):

An instance method mC declared in or inherited by class C, overrides from C another method mA declared in class A, iff all of the following are true:

Copy link
Member

Choose a reason for hiding this comment

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

Then we should use
String.format("%s does not override from %s %s", tm, t.getQualifiedName(), sm). sm is not from t, the override is instead.

Copy link
Member

Choose a reason for hiding this comment

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

If you go with that, consider adding the word "method" in between the last two placeholders to clearly separate them:

from %s method %s"

* questions.
*/

class S {
Copy link
Member

@jddarcy jddarcy Jan 7, 2025

Choose a reason for hiding this comment

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

Following the usual conventions for annotation processing tests, it would be possible (and IMO desirable) for these declarations to be included in the same file as the test scaffolding, assuming S compiles.

If S does not compile, that should be documented.


import static javax.lang.model.element.ElementKind.METHOD;

/*
Copy link
Member

Choose a reason for hiding this comment

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

This comment would be helpful immediately before S and it would also be helpful for the various conditions being tested to be documented via comments.

@nizarbenalla
Copy link
Member Author

Thanks for the reviews, Updated accordingly.

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 20, 2025

@nizarbenalla This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@nizarbenalla
Copy link
Member Author

/open

@jddarcy, could you re-review this PR?

@openjdk
Copy link

openjdk bot commented Feb 20, 2025

@nizarbenalla This pull request is already open

* @apiNote It may not implement the additional compile-time checks on exception types,
* return types, and method modifiers specified in JLS {@jls 8.4.8.1} and {@jls 8.4.8.3},
* although implementations of this method are allowed to implement these additional checks.
*
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the current wording conveys enough context for the reader. I suggest a structure like:

apiNote
This method must examines X, Y, and Z in determining whether one method overrides another. In addition, an implementation may have a stricter checking including at properties A, B, and C as described in JLS ..."

HTH

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 in e21de7d -- Sorry for the delay.

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 25, 2025

@nizarbenalla This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@nizarbenalla
Copy link
Member Author

Keep alive.

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.

These update notes look good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 25, 2025
@jddarcy
Copy link
Member

jddarcy commented Apr 29, 2025

/csr needed

Copy link
Member

@jddarcy jddarcy left a comment

Choose a reason for hiding this comment

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

Current version of the javadoc update looks fine.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Apr 29, 2025
@openjdk
Copy link

openjdk bot commented Apr 29, 2025

@jddarcy has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@nizarbenalla please create a CSR request for issue JDK-8174840 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated csr Pull request needs approved CSR before integration labels Apr 29, 2025
@nizarbenalla
Copy link
Member Author

CSR request has been approved. Thank you all for the reviews!
/integrate

@openjdk
Copy link

openjdk bot commented May 5, 2025

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

openjdk bot commented May 5, 2025

@nizarbenalla Pushed as commit 606f201.

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

@nizarbenalla nizarbenalla deleted the elements-api-note branch May 5, 2025 21:52
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

Development

Successfully merging this pull request may close these issues.

4 participants