[JSR308] Proposal: Multiple Instance of same Annotation, Annotation Inheritance
mernst at csail.mit.edu
Mon Oct 6 15:23:11 EDT 2008
Thanks for your cogent proposal. It's refreshing that you both thought
through the issues (including expanding on some incomplete points from the
Type Annotations Specification) and asked if others are aware of additional
issues. And, finally, thanks for your willingness to help! Things don't
get done by just making requests or proposals, but by rolling up our
I don't see any obvious show-stopper problems with your proposal.
I like your example of XML as a motivation for the need for users to
specify annotations that express data-structure-like information. I
suspect you're right that users will come up with unforeseen purposes for
such annotations. However, I would be much more comfortable with the
proposal if it provided some real, concrete use case and benefits for
substantial numbers of programmers today. Such compelling examples aren't
really optional: they are a necessary counterweight to the risks and
effort inherent in any change to Java.
I also want to briefly respond to your high-level summary.
> I would like to propose that the current annotation system be extended
> in two ways.
> 1. The first would be to allow for multiple annotations of
> the same type to be attached to the same program statement. This is
> already mentioned in Section D.1 of the Type Annotations
> 2. The other would be to allow for inheritance among annotations.
> Together, I think that these two ideas permit far more
> flexibility than the current annotation scheme.
Note that your extension #2, inheritance among annotations, is discussed in
appendix D.4.1 of the JSR 308 specification.
Also, there is a third extension that your proposal implicitly assumes:
3. Permit an annotation to take arbitrary annotations as arguments. This
is mentioned in appendix D.4.2 of the Type Annotations Specification.
In particular, you said
> [In] the current annotation scheme
> ... it would be possible to have @Nodes that contain either @Nodes or
> @Leafs, but not both.
but in Java 6, having @Nodes that contain @Nodes is illegal.
Thanks again for your useful contribution.
More information about the JSR308