[JSR308] Default annotations

Neal Gafter gafter at google.com
Sat Feb 24 22:42:58 EST 2007

On 2/24/07, Michael Ernst <mernst at csail.mit.edu> wrote:
> Specifying a default for annotations can reduce code size and (when used
> carefully and sparingly) increase code readability.
> For instance, Figure 1 of the JSR 308 proposal (which is available at
>   http://pag.csail.mit.edu/jsr308/java-annotation-design.pdf
>   http://pag.csail.mit.edu/jsr308/java-annotation-design.html
> ) uses @NonNullDefault to avoid the clutter of  5 @NonNull annotations.
> But it would be nicer to have a general mechanism, such as
>   @DefaultAnnotation(NonNull.CLASS, locations={ElementType.LOCAL_VARIABLE
> })
> It would be even better to be able to specify the arguments to the
> defaulted annotation, as in
>   @DefaultAnnotation(@MyAnnotation(arg="foo"))
> but that is not currently possible -- we would have to extend the Java
> syntax in a new way to accommodate it.
> Should the issue of default annotations be taken up by us (JSR 308) or by
> JSR 305?  (Recall that JSR 305 is defining a set of annotations, along
> with
> their semantics. For instance, it is JSR 305's role to decide whether Java
> programmers will write @NonNull or @Nonnull or @NotNull, and what it means
> when they write it.)

No, I do not think that the issue of default annotations should be taken up
by us or by jsr305.  I don't see it as being in scope for either JSR.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20070224/0d37ef2f/attachment.html

More information about the JSR308 mailing list