-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8174840: Elements.overrides does not check the return type of the methods #22920
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
Conversation
…irement on the implementation.
|
👋 Welcome back nbenalla! A progress list of the required criteria for merging this PR into |
|
@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: 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
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 |
|
@nizarbenalla The following label will be automatically applied to this pull request:
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. |
| * on thrown types, return types and those constraints on method modifiers not directly | ||
| * bound to the overriding relation as such. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Webrevs
|
|
/contributor add prappo |
|
@nizarbenalla |
| @@ -0,0 +1,52 @@ | |||
| /* | |||
| * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
mCdeclared in or inherited by classC, overrides fromCanother methodmAdeclared in classA, iff all of the following are true:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; | ||
|
|
||
| /* |
There was a problem hiding this comment.
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.
|
Thanks for the reviews, Updated accordingly. |
|
@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! |
|
/open @jddarcy, could you re-review this PR? |
|
@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. | ||
| * |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
@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! |
|
Keep alive. |
There was a problem hiding this 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.
|
/csr needed |
There was a problem hiding this 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.
|
@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. |
|
CSR request has been approved. Thank you all for the reviews! |
|
Going to push as commit 606f201.
Your commit was automatically rebased without conflicts. |
|
@nizarbenalla Pushed as commit 606f201. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this PR to clarify the documentation of
Elements.overridesthrough an@apiNote, this PR is essentially a doc-only change. This PR supersedes #22244.TIA.
Progress
Issues
Reviewers
Contributors
<prappo@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22920/head:pull/22920$ git checkout pull/22920Update a local copy of the PR:
$ git checkout pull/22920$ git pull https://git.openjdk.org/jdk.git pull/22920/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22920View PR using the GUI difftool:
$ git pr show -t 22920Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22920.diff
Using Webrev
Link to Webrev Comment