Type Annotations clarification

Alex Buckley alex.buckley at oracle.com
Fri Mar 7 18:29:57 UTC 2014


Werner, I agree with your assessment - but please note that you are 
confusing _component type_ with _element type_. They are not the same. 
For example, the component type of Outer.Inner[][] is Outer.Inner[], and 
that's where @D lives, whereas the element type of Outer.Inner[][] is 
Outer.Inner, and that's where @A and @B live.

Alex

On 3/7/2014 9:50 AM, Werner Dietl wrote:
> Hi Eric,
>
> it would help make the discussions concrete, if you sent complete
> programs that each of us can test.
> I've extended your example to:
>
> ===
> import java.lang.annotation.*;
>
> class Outer {
>    class Inner {}
> }
>
> class Use {
>    @A Outer. @B Inner @C [] @D [] f;
> }
>
> @Target(ElementType.TYPE_USE)
> @interface A { };
>
> @Target(ElementType.TYPE_USE)
> @interface B { };
>
> @Target(ElementType.TYPE_USE)
> @interface C { };
>
> @Target(ElementType.TYPE_USE)
> @interface D { };
> ===
>
> I get the following type annotations for field f, where #10 is C, #11
> is D, #12 is B, and #13 is A:
>
>      RuntimeInvisibleTypeAnnotations:
>        0: #10(): FIELD
>        1: #11(): FIELD, location=[ARRAY]
>        2: #12(): FIELD, location=[ARRAY, ARRAY, INNER_TYPE]
>        3: #13(): FIELD, location=[ARRAY, ARRAY]
>
> This seems correct to me:
> - @A is on Outer, so no INNER_TYPE is required. It is on the component
> type of a two-dimensional array, so two ARRAY are correct.
> - @B is on Inner, so it additionally takes one INNER_TYPE.
> - @C is on the outermost-array type, so no location is called for.
> - @D is on the second array dimension, so one ARRAY location is needed.
>
> Note that the array component type is "Outer.Inner". The array types
> are not nested and do not need an INNER_TYPE.
> Why do you say that @A should have an INNER_TYPE?
>
> cu, WMD.
>
>
> On Fri, Mar 7, 2014 at 12:35 PM, Eric McCorkle <eric.mccorkle at oracle.com> wrote:
>> Hello,
>>
>> I need clarification for a specific case:
>>
>> class Outer {
>>    class Inner {}
>> }
>>
>> And a type use of:
>>
>> @A Outer.Inner @B [] @C []
>>
>> The type path for @A is clearly [ARRAY, ARRAY, INNER_TYPE]
>>
>> However, should the type path for @B and @C contain an INNER_TYPE as well?
>
>
>


More information about the type-annotations-dev mailing list