Clarification on type use

Alex Buckley alex.buckley at oracle.com
Thu Apr 3 22:15:28 UTC 2014


The @A on the class declaration is a _declaration annotation_ (JLS 
9.7.4), so Runtime[In]VisibleAnnotations is the right attribute.

Alex

On 4/3/2014 2:24 PM, Werner Dietl wrote:
> Alex,
>
> I agree that the annotation is legal in that location.
> One point I'm not sure in is:
>
> "The result with the current implementation is that javac produces a
> RuntimeInvisibleAnnotations attribute for the class TypeUseTarget."
>
> Should a TYPE_USE annotation always be in a
> RuntimeInvisibleTYPEAnnotations attribute?
> A TYPE annotation appears in the RuntimeInvisibleAnnotations
> attribute, so I find the current behavior consistent.
>
> cu, WMD.
>
>
> On Thu, Apr 3, 2014 at 4:07 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
>> Yes. TYPE or TYPE_PARAMETER, actually.
>>
>>
>> On 4/3/2014 1:05 PM, Paul Benedict wrote:
>>>
>>> I once heard someone say that TYPE_USE is a parent of TYPE. Thus,
>>> wherever a valid TYPE can appear, a TYPE_USE would also be valid in the
>>> same place. Right/wrong?
>>>
>>>
>>> On Thu, Apr 3, 2014 at 2:27 PM, Alex Buckley <alex.buckley at oracle.com
>>> <mailto:alex.buckley at oracle.com>> wrote:
>>>
>>>      Eric, I am on type-annotations-dev, you don't need to cc me every
>>> time.
>>>
>>>      The TYPE_USE enum constant is specified in the javadoc for the
>>>      j.l.a.ElementType enum type: "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."  ["15" should be "16", there's a
>>>      bug out for that.]
>>>
>>>      Alex
>>>
>>>      On 4/3/2014 9:19 AM, Eric McCorkle wrote:
>>>
>>>          The following is exerpted from the test
>>>
>>> langtools/test/tools/javac/__annotations/typeAnnotations/__TypeUseTarget.java:
>>>
>>>
>>>          @A
>>>          class TypeUseTarget<K extends @A Object> {
>>>          ...
>>>          }
>>>
>>>          @Target(ElementType.TYPE_USE)
>>>          @interface A { }
>>>
>>>
>>>          The first use of A seems to be on the class TypeUseTarget.  The
>>>          result
>>>          with the current implementation is that javac produces a
>>>          RuntimeInvisibleAnnotations attribute for the class TypeUseTarget.
>>>
>>>          But is this valid?  I can't seem to find anything in the type
>>>          annotations spec that suggests that an annotation with a
>>>          TYPE_USE target
>>>          can wind up being a regular annotation on a class (or interface).
>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Paul
>
>
>


More information about the type-annotations-dev mailing list