[JSR308] Re: Backward compatibility for ElementType meta-annotations
pugh at cs.umd.edu
Tue Jul 17 22:03:03 EDT 2007
It is a little more complicated than that. JSR-305 will be defining
meta-annotations that allow anyone to define their own type qualifier
annotations. Thus, even if Java 7 updates the annotations defined by
JSR-305, there will (hopefully) be third-party type qualifier
annotations that won't get updated, and that may have to be portable
across Java 5, 6 and 7 versions.
But, I'm not sure this is a big issue. What does the disambiguation
actually effect? What happens if you have an annotation that can be
applied to either a TYPE or a METHOD applied to a method. So long as
JSR-308 doesn't barf and complain that it is ambiguous, I don't think
it will be a problem.
On Jul 16, 2007, at 6:40 PM, Michael Ernst wrote:
>> The document suggests (Section 3.3) that we can use ElementType
>> declarations to disambiguate whether an annotation applies to a
>> method or a return value.
>> However, this is not compatible with pre-JSR308 usage, and won't be
>> compatible with JSR305.
> JSR 308 could include new versions of the JSR 305 annotations; the new
> versions would have JSR-308-compatible meta-annotations. (For
> example, the
> new version of NonNull would have an ElementType.TYPE meta-
> Users of a JSR 308 compiler will have the new version first on their
> classpath, and users of a non-JSR-308-aware tool will use the old
> of NonNull (meta-annotated with ElementType.METHOD).
> I think this permits re-use of the same syntax without rewriting
> code in order to upgrade to JSR 308 or Java 7, but let me know if I am
> missing something. (I have some other ideas if this doesn't work.)
> PS: Sorry for the delay in answering these emails; I've been
> traveling and
> have fallen behind on email.
More information about the JSR308