TYPE_USE annotations in declaration contexts

Alex Buckley alex.buckley at oracle.com
Thu Feb 6 11:55:35 PST 2014


The goal of 9.6.4.1 is not to mirror the javadoc text, but to formally 
introduce _declaration contexts_ and _type contexts_ for the benefit of 
9.7.4 and 9.7.5. The contexts are introduced in 9.6.4.1 so that the 
javadoc can also rely on them when specifying how @Target(TYPE), 
@Target(TYPE_USE), etc, are interpreted. 9.6.4.1 doesn't actually 
specify @Target(TYPE_USE).

Alex

On 2/6/2014 9:01 AM, Markus Keller wrote:
> The Javadoc of java.lang.annotation.ElementType says: "The constant
> TYPE_USE corresponds to the 15 type contexts in JLS 4.11, as well as to
> two declaration contexts: type declarations (including annotation type
> declarations) and type parameter declarations."
>
> java-se-8-jls-fr-diffs.pdf 9.6.4.1 says: "There are 15 type contexts
> (§4.11), all represented by the enum constant TYPE_USE of
> java.lang.annotation.ElementType."
>
> => JLS8 doesn't tell that TYPE_USE annotations are also applicable in two
> declaration contexts. This should be added to JLS8 9.6.4.1.
>
> Current implementations of javac and ecj follow the Javadoc (accept a
> TYPE_USE annotation on a type declaration) and thus violate the current
> JLS8.
>
> Regards,
> Markus
>


More information about the type-annotations-spec-comments mailing list