- 
                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 #22244
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
| 👋 Welcome back prappo! A progress list of the required criteria for merging this PR into  | 
| ❗ This change is not yet ready to be integrated. | 
| @pavelrappo 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. | 
| Webrevs
 | 
| * questions. | ||
| */ | ||
|  | ||
| public 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.
If all these testing types could be put into the single test file, that would be preferable.
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 condensed all the testing types in just one file. I couldn't put them further, in TestOverrides.java itself, because they would make it non-compilable. Additionally, I removed public from class S for symmetry: it shouldn't be special.
| * @apiNote The notion of overriding, by itself, does not involve the | ||
| * method's return type, listed exceptions, or, to some extent, access | ||
| * modifiers. These are additional requirements checked by the compiler | ||
| * (see {@jls 8.4.8.3}). | 
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.
Nit: use something like
(see JLS {@jls 8.4.8.3}).
as currently written, this would just render a section number pointing to a page.
| * — such as when processing annotations — the additional | ||
| * requirements might not be checked, potentially causing this method | ||
| * to return a false positive. | ||
| * | 
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 gist of this paragraph is good; some refinement is needed to not imply any particular requirements on the implementation, something like :"An implementation [of annotation processing] may choose to not check the additional requirements [under some limited conditions]".
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.
Please correct me if I am wrong, but:
- reading JLS 8.4.8.1 and JLS 8.4.8.3, 8.4.8.1 defines the "overrides" relation between two methods, and this relation does not include return type, throw exception, and to some degree modifiers. These are additional conditions, but these are conditions like "if m_Coverridesm_A(when viewed fromC)", and condition is met a compile-time error occurs. I.e. the fact that there e.g. an incorrect throws clause does not mean thatm_Cdoes not overridem_A(when viewed fromC), it only means a compile-time error occurs.
- the Elements.overridesmethod strives to implement the relation, not the additional checks.
I agree it is reasonable to include a warning that only the relation is checked, not the additional constraints. But I find the wording "has not been sufficiently compiled" fairly confusing. I would try to point out this method only implements the "overrides" relation, not the additional constraints that are not part of the relation as such, as defined in JLS 8.4.8.1 and JLS 8.4.8.3. And hence, the two methods may satisfy the "overrides" relation, but still be part of erroneous code.
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 gist of this paragraph is good; some refinement is needed to not imply any particular requirements on the implementation, something like :"An implementation [of annotation processing] may choose to not check the additional requirements [under some limited conditions]".
I tried to rephrase it the way you seem to have proposed; is that better?
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.
My idea was something along these lines:
This method implements the overrides relation as specified in JLS 8.4.8.1. It does not implement the additional compile-time checks that Java compilers follow, specified in JLS 8.4.8.1 and 8.4.8.3, in particular the additional constraints on thrown types, return types and those constrains on method modifiers not directly bound to the overriding relation as such.
As I understand now, there may be implementations that also do the additional checks, so if we that should be permitted, the it could say "may not", instead of "does not".
Not sure if this makes 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 hear you: the Java Language Specification separates "overrides" from those additional checks.
So, if Elements.overrides models "overrides", it is under no obligation to perform those checks. Moreover, I think, it might not be always possible to perform them. Still, I believe we should NOT say that this method always skips them. So your "may not" is better.
Here's why. Whether any additional checks are performed seems to be implementation-dependant. For example, here's how ECJ (Eclipse) runs that same test (after some necessary modifications to decouple the test from our test infrastructure):
% java -jar ecj-4.33.jar --release 22 -classpath . -processor TestOverrides -proc:only S.java
1. ERROR: protected void m()  does not override public void m()  from T1
2. ERROR: void m()  does not override public void m()  from T2
3. ERROR: private void m()  does not override public void m()  from T3
3 problems (3 errors)
- Reduce the number of files - Rephrase apiNote
| @pavelrappo 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! | 
| @jddarcy can we address this soon, or we should postpone this until after New Year? | 
| Keep alive. | 
| This PR has been superseded by #22920. Please continue the discussion and review there. | 
Please review this essentially doc only change.
Progress
Error
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22244/head:pull/22244$ git checkout pull/22244Update a local copy of the PR:
$ git checkout pull/22244$ git pull https://git.openjdk.org/jdk.git pull/22244/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22244View PR using the GUI difftool:
$ git pr show -t 22244Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22244.diff
Using Webrev
Link to Webrev Comment