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
8231436: Fix the applicability of a no-@Target annotation type #2303
Conversation
👋 Welcome back cushon! A progress list of the required criteria for merging this PR into |
Webrevs
|
Hi Liam, Code looks good, but I'd prefer if you file a more specific bug. Maybe also add a small test that doesn't compile before the fix? |
/csr |
@jddarcy has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
Please file a CSR so that the behavioral compatibly change can be assessed. |
Thanks for the comments, @jbf I'll add a more focused test. For the bug, the original discussion in https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013705.html is specifically about annotations without an explicit @jddarcy note that there was already a spec change related to this in JDK-8231435 and the spec bug mentions "this expansion is source, binary, and behaviorally compatible", should I still file a CSR? |
From this follow up here: https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013715.html my interpretation is that this bug was intended to widen it to all contexts, including type use. This has been changed in JLS but not in the normative javadoc and also not in the compiler. I believe we should keep declarations only, and back out the change to JLS. |
Maybe we should collect the concrete information about this problem. Here are some materials that I know. Order by time:
[1] https://mail.openjdk.java.net/pipermail/compiler-dev/2019-August/013666.html |
Mailing list message from Alex Buckley on compiler-dev: I initially proposed "all declaration contexts" as the smallest possible Alex On 2/2/2021 3:44 AM, Guoxiong Li wrote: |
Mailing list message from Joel Borggren-Franck on compiler-dev: Hi Alex, Looking at the class file, and therefore reflection, there is a difference between ?all declaration contexts? and ?all contexts, declaration + type?. For the 5 ambiguous locations we would have to produce type annotation attributes if there is an annotation present whose declaration lack @target. While this may or may not be desirable, and I?m leaning towards not, it is surely significant as it would change the semantics of reflective annotation processors in use. cheers
|
Mailing list message from Joe Darcy on compiler-dev: Hello, To me, it seems that intending an annotation to be used on declarations Cheers, -Joe On 2/3/2021 5:29 AM, Joel Borggren-Franck wrote:
|
Thanks, I was missing context here. I now realize this patch is fixing a bug related to JDK-8254023--when the handling of annotations without I'm also happy to help with any work to be done on the larger question of interpreting |
Mailing list message from Alex Buckley on compiler-dev: Let me focus first on the design question of what a no- at Target (We could have said "all contexts" for a no- at Target annotation type but Turning to the compatibility concern: yes, JDK-8231435 shouldn't have I have cc'd Mike in case he wants to add anything further, but the Alex On 2/3/2021 5:29 AM, Joel Borggren-Franck wrote:
|
I spun the original change that related specifically to repeatable annotations and I will look at updating this review to actually implement the change to make no- |
I pushed an initial implementation of a fix to make no- I have updated affected tier 1 langtools tests, which provides some signal about the compatibility impact. That also uncovered a couple of bugs: one issue where javadoc isn't escaping type annotations in html (JDK-8261203), and a crash with intersection types and LVTI (JDK-8261205). |
Mailing list message from Joel Borggren-Franck on compiler-dev: Hi, Some comments inline,
I agree that had we done this in one go from scratch, it seems likely that the ?all contexts? default for no- at Target annotation would have been chosen.
FYI this is what ecj does. They allow all contexts but don?t generate type annotation attributes from the ambiguous contexts.
In isolation yes, ?all contexts? makes sense, but so does ?all declaration contexts?. What worries me here is that we change the semantics of programs written as far back as 2004. While I don?t think this is an absolute no, we shouldn?t do this lightly, the gain should be substantial, and the risk well quantified. One aspect here is that while annotation interface declarations without @target might very well be poorly written, it is/was still the only way to specify "all current and future declaration targets?, it is/was also the only alternative with some brevity to specify all current declaration contexts, the alternative being to type out 9 ElementTypes. An alternative would be to adopt your original proposal, ?all current and future declaration contexts?, and adding an ElementType corresponding to this default. This way the question ?where are annotations applicable?? would be solved, the user can easily and with brevity opt in to all contexts by using something like ?@target({DECLARATIONS, TYPE_USE})" and the backward compatibility risk is lower. The downside is It would mean more work for us in implementing this. cheers |
Mailing list message from Alex Buckley on compiler-dev: On 2/5/2021 6:44 AM, Joel Borggren-Franck wrote:
The original meaning of no- at Target in 2004 was open-ended, the "all When Java 8 added annotations on declarations of type parameters (a I think your dislike of no- at Target meaning "all contexts" is not that it The corner case is a fact of Java life (and I might even concede it's Encouraging the owner to specify @target by offering an (In Java 15, TYPE_USE implied 16 type contexts; in Java 16, TYPE_USE Alex
|
Mailing list message from Liam Miller-Cushon on compiler-dev: On Fri, Feb 5, 2021 at 6:45 AM Joel Borggren-Franck <
On Fri, Feb 5, 2021 at 12:15 PM Alex Buckley <alex.buckley at oracle.com>
I had a similar thought while updating the affected tests: I don't have a strong opinion either way about whether this change is worth If there's a tentative agreement that making @Target-less annotations apply |
Mailing list message from Alex Buckley on compiler-dev: On 2/5/2021 4:18 PM, Liam Miller-Cushon wrote:
Suppose that the no- at Target annotation @foo is today a declaration Of course a type-checking annotation processor might be calling Is there a compatibility impact I am overlooking? Alex |
Mailing list message from Liam Miller-Cushon on compiler-dev: On Fri, Feb 5, 2021 at 4:52 PM Alex Buckley <alex.buckley at oracle.com> wrote:
I don't think there's anything major, it's just the usual concern that this The least contrived example I can think of is that an annotation processor The additional attributes in the class file will also make them slightly I agree that being able to add an explicitly @target to annotations where If I was writing a CSR for this I'd probably estimate the compatibility [1] https://www.hyrumslaw.com/ <https://www.hyrumslaw.com/> |
Mailing list message from Alex Buckley on compiler-dev: On 2/5/2021 5:13 PM, Liam Miller-Cushon wrote:
Yes. The real issue is that _any_ open-ended definition, even the
a.k.a. Martin Buchholz's "Every change is an incompatible change." |
Mailing list message from Brian Goetz on compiler-dev: We appear to have painted ourselves into a corner quite nicely. In Java 5, the interpretation of "a no- at Target annotation (NTA) is I agree with Joel that:
but, we didn't do this in one go from scratch.? I also agree with Joe
The concern now seems mostly to be about "but, there are old moldy So I agree with Joe that:
and prefer that we leave the existing interpretation of "all declaration On 2/3/2021 1:39 PM, Alex Buckley wrote:
|
Mailing list message from Alex Buckley on compiler-dev: On 2/9/2021 6:34 AM, Brian Goetz wrote:
Thanks Brian. I will proceed with that policy by filing a new spec bug A coarse DECLARATIONS target that explicitly indicates "all declaration Alex |
Mailing list message from Liam Miller-Cushon on compiler-dev: On Thu, Feb 11, 2021 at 9:52 AM Alex Buckley <alex.buckley at oracle.com>
Thanks all. I will close this review. To confirm, is there still consensus that "all declaration contexts" for |
Mailing list message from Alex Buckley on compiler-dev: On 2/11/2021 11:28 AM, Liam Miller-Cushon wrote:
I have filed spec bug https://bugs.openjdk.java.net/browse/JDK-8261610 Since the javac bug JDK-8231436 never got beyond New status, I think it
Yes. The spec bug discusses the open-ended nature of "all declaration Alex |
Mailing list message from Michael Ernst on compiler-dev: I concur with Alex: an annotation defined without a @Target annotation Mike On Wed, Feb 3, 2021 at 10:39 AM Alex Buckley <alex.buckley at oracle.com>
-------------- next part -------------- |
1 similar comment
Mailing list message from Michael Ernst on compiler-dev: I concur with Alex: an annotation defined without a @Target annotation Mike On Wed, Feb 3, 2021 at 10:39 AM Alex Buckley <alex.buckley at oracle.com>
-------------- next part -------------- |
Please review this fix to add
ElementType.MODULE
to the default list of annotation targets, to allow annotations without an explicit@Target
to be used on module declarations.Progress
Integration blocker
Issue
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2303/head:pull/2303
$ git checkout pull/2303