Spec clarification, where are annotations without @Target applicable?
Joel Borggrén-Franck
joel.p.borggren-franck at oracle.com
Wed Dec 2 14:11:35 UTC 2020
Hi,
Thanks for the background Werner. I'm very sympathetic to the idea of
not having to answer this kind of question again but it seems we are not
yet there with two competing normative specifications and a reference
implementation that implements neither.
Short term (Java 16) it makes sense to fix
https://bugs.openjdk.java.net/browse/JDK-8254023 given that both
competing specs agree for this case, it is a small fix, and externally
found.
For Java 17 we should align both specs and the reference implementation
one way or another.
cheers
/Joel
On 2020-10-19 15:11, Werner Dietl wrote:
> I think this is a relevant discussion:
>
> https://mail.openjdk.java.net/pipermail/compiler-dev/2019-August/013666.html
> <https://mail.openjdk.java.net/pipermail/compiler-dev/2019-August/013666.html>
>
> https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013715.html
> <https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013715.html>
>
> cu, WMD.
>
> On Mon, Oct 19, 2020 at 6:34 AM Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>
> The JLS 13 text seems right to me. The ambiguity between deco and
> type contexts makes “all contexts” problematic. I don’t recall
> this change as a “decision”.
>
> Sent from my iPad
>
> > On Oct 19, 2020, at 5:49 AM, Joel Borggrén-Franck
> <joel.p.borggren-franck at oracle.com
> <mailto:joel.p.borggren-franck at oracle.com>> wrote:
> >
> > Hello JLS experts,
> >
> > When reviewing the proposed fix for annotations not being
> applicable to modules by default [3] I noticed that the Javadoc
> [1] and JLS wording [2] for which annotation contexts are
> applicable by default have diverged since Java 14. The javaoc for
> j.l.a.Target keeps the old wording:
> >
> > "If an @Target meta-annotation is not present on an annotation
> type T, then an annotation of type T may be written as a modifier
> for any declaration except a type parameter declaration."
> >
> > While the JLS since 14 states:
> >
> > "If an annotation of type java.lang.annotation.Target is not
> present on the declaration of an annotation type T, then T is
> applicable in all nine declaration contexts and in all 16 type
> contexts."
> >
> > vs JLS 13:
> >
> > "If an annotation of type java.lang.annotation.Target is not
> present on the declaration of an annotation type T, then T is
> applicable in all declaration contexts except type parameter
> declarations, and in no type contexts.
> >
> > These contexts are the syntactic locations where annotations
> were allowed in Java SE 7."
> >
> > I can't find any mention of this change in a CSR so it is not
> yet clear to me if the Javadoc or the JLS needs to be updated.
> >
> > cheers
> > /Joel
> >
> > [1]
> https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/annotation/Target.html
> <https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/annotation/Target.html>
>
> > [2]
> https://docs.oracle.com/javase/specs/jls/se15/html/jls-9.html#jls-9.6.4.1
> <https://docs.oracle.com/javase/specs/jls/se15/html/jls-9.html#jls-9.6.4.1>
> > [3] https://github.com/openjdk/jdk/pull/622
> <https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/622__;!!GqivPVa7Brio!P7C91ceDLayE0UpDfpsSkSoQHUnJnVUAxQ1Noo5KlOn6pXIFkpKOn6Ie5C9-MEFAtj5R7qRDFNk$>
> >
>
>
>
> --
> https://ece.uwaterloo.ca/~wdietl/
> <https://urldefense.com/v3/__https://ece.uwaterloo.ca/*wdietl/__;fg!!GqivPVa7Brio!P7C91ceDLayE0UpDfpsSkSoQHUnJnVUAxQ1Noo5KlOn6pXIFkpKOn6Ie5C9-MEFAtj5RYyfhlAQ$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20201202/18098880/attachment-0001.htm>
More information about the compiler-dev
mailing list