[JSR308] Re: Backward compatibility for ElementType meta-annotations
Michael Ernst
mernst at csail.mit.edu
Tue Jul 17 23:11:49 EDT 2007
Bill-
> JSR-305 will be defining
> meta-annotations that allow anyone to define their own type qualifier
> annotations.
OK. JSR 308 makes it easy for users to define fully-featured type
qualifier annotations and checkers. I haven't heard any details of your
proposal, but if and when you flesh it out, please do coordinate with JSR
308 in order to avoid unnecessary incompatibilities or duplicated work.
> What happens if you have an annotation that can be
> applied to either a TYPE or a METHOD applied to a method.
The JSR 308 proposal states (in section 3.3):
The compiler applies the annotation to every target that is consistent
with its meta-annotation.
Thus, the annotation would appear in both locations. This is a reasonable
way to get backward compatibility (at the cost of the ElementType
meta-annotations containing ElementType.METHOD, which they shouldn't in a
Java 7 context).
I anticipate that people who define type qualifier annotations may decide
to re-implement their checkers for JSR 308 (Java 7), since it offers much
more functionality than Java 5 annotations. (For example, type qualifiers
that can't be conveniently applied to generic type arguments are far less
expressive.) That, too, would moot the question, but at least there is a
compatibility story for orphaned type qualifier annotations.
-Mike
More information about the JSR308
mailing list