[JSR308] array-valued annotations
Joe.Darcy at Sun.COM
Sun Jan 28 17:23:23 EST 2007
Eugene Kuleshov wrote:
> Joe Darcy wrote:
>>> 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, can you please elaborate why is that would be incompatible?
> Array-level annotation will be a new construct that won't be present in
> the old code.
Yes, but if existing code, like the core JDK libraries, is retrofitted
to use these new features, than old code and new code will interact and
a source incompatibility could be introduced.
Even if such retrofitting is not done (and not intended), the
complications of having fundamentally different de facto typing rules
for arrays types with certain kinds of annotations and array types
without those annotations is undesirable (even if it is necessary).
During JDK 5 development, the rules for combining arrays and generics
evolved, but they are still a source of complexity and confusion.
Adding news rules for annotations could exacerbate the situation.
> However new code and new annotation processors (not only the source
> level ones like in JSR 269) could use these new constructs.
FYI, both apt and JSR 269 annotation processors can operate on class
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
More information about the JSR308