[JSR308] Section 3.3 (disambiguation of type and declaration
pugh at cs.umd.edu
Thu Aug 2 11:18:28 EDT 2007
I don't understand the purpose of section 3.3 (disambiguation of type
and declaration annotations), or how it would work.
1) What do you do if an annotation states that it can be applied to
both a method and a type?
2) The example of disambiguating @Deprecated and @Nonnull is broken,
since @Deprecated can be applied to either a method or a type.
3) What impact does the "disambiguation" have? It seems that the only
difference is whether an annotation or an extended_annotation
attribute is generated. Is that correct?
4) I don't understand the asymmetry between field/field types and
method/method return types. Why does field but not field type appear
in Table 2, while method type type but not method appears in Table 2?
Overall, I'm very concerned about anything that would require
compiling a specific source file would put annotations in different
locations, depending on whether the target was java 5 or java 7. '
JSR-305 will define type qualifier annotations that can be applied to
ElementType.TYPE, ElementType.Field, ElementType.Method. More
importantly, it will define meta-annotations that will enable
hundreds of people to define their own type qualifier annotations,
which will also be defined as being applicable to both TYPE and
METHODS. Actually, you should be hoping that most people don't define
the locations where their annotations can be applied, since then they
won't be applicable to any of the new locations allowed under Java 7.
In conclusion, I don't see that JSR-308 has to disambiguate between
annotations on a method and annotations on the return type of the
method, or between annotations on a field and annotations on the
field type. Leave it up to the consumer of the annotations to do that
More information about the JSR308