[JSR308] Proposal: Multiple Instance of same Annotation, Annotation Inheritance
Niko Matsakis
niko at alum.mit.edu
Wed Oct 8 04:06:33 EDT 2008
> 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 completely agree that this section of my proposal was lacking. In
fact, I delayed sending it for some time because I wanted to work in a
better example: however, I eventually decided to send it "as is" in
the hope that it might prompt a discussion from which I could draw
better use cases. It seems that there have in fact been many e-mails
recently calling for annotation inheritance which can serve as a basis
for those use cases.
With respect to the timing, I am not sure what is the expected time
span for JSR-308. I assume there is some sort of deadline for a final
draft of the specification, reference implementation, etc?
>> [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.
Yes, good point. To handle my example, it would be necessary to
permit recursive/cyclic references that occur within arrays. As
discussed in the JSR-107 FAQ, this does indeed raise the possibility
of infinite annotation instances through the use of defaults, unless a
more involved restriction were put in place.
regards,
Niko Matsakis
More information about the JSR308
mailing list