Type Annotations clarification

Werner Dietl wdietl at gmail.com
Fri Mar 7 17:50:25 UTC 2014

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;

@interface A { };

@interface B { };

@interface C { };

@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:

      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 compiler-dev mailing list