[JSR308] array-valued annotations

Joe Darcy Joe.Darcy at Sun.COM
Sun Jan 28 16:17:46 EST 2007


I joined the mailing list recently; previously I was the spec lead for 
JSR 269, which added a standardized annotation processing API to JDK 6.

Michael Ernst wrote:
> Ted-
>> a multidimensional array has to contain all the same type,
>> regardless of the number of dimensions.
> I agree that the type at the "leaves" must all be the same -- and they
> must all have the same annotation.
> However, Java does support different types at different levels of an
> array.  For instance, consider an array of type Document[][].
>  * The first level of the array has type Document[][].
>  * The next level (i.the first level's elements) has type Document[].
>  * The final level (the leaves) has type Document.
> These are distinct types, though Java enforces that they have a
> specific relationship to one another.

At runtime these specific constraints are enforced via a store check 
that relies on reified information about the array's type.  I believe 
adding similar reification of annotation information would be 
problematic and at compile time only accepting programs that didn't need 
such runtime checks would be too incompatible.

-Joe Darcy
  joe.darcy at sun.com

> It seems useful to permit different annotations on the distinct types
> at each level.  However, the types/annotations at different levels
> should have specific relationships to one another, just as array types
> already do.  The syntax can enforce this, just as that for array types
> already does.  For instance, you correctly note that the type
> "Document[Object[]]" makes no sense; and the Java syntax makes it
> impossible to write such a nonsensical type.
>                     -Michael Ernst
>                      mernst at csail.mit.edu
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308

More information about the JSR308 mailing list