Re: Type annotation appears before the type’s simple name
wdietl at gmail.com
Thu Dec 13 12:06:50 PST 2012
thanks for your interest in type-annotations and your comments.
This is the developers mailing list. For questions to the EG you have
to message the type-annotations-spec-comments mailing list.
This syntax was recently changed, as raised by Srikanth:
I do prefer this new syntax and was advocating for it when we
initially discussed this issue.
To me, it is more logical to have the annotation right before the
element you want to annotate.
Also, it made the implementation in OpenJDK significantly simpler.
In your first examples:
> 1a) Map. at NonNull Entry
> 1b) @NonNull Map.Entry
In the old approach (example 1b), it depends on whether class
Map.Entry is a static inner class or not to decide where the
For non-static nested classes, all three of the following are possible:
Outer. @A Inner
@A Outer. @B Inner
It makes parsing easier if this semantic knowledge is not needed to
decide where to attach the annotation.
Similarly for package names:
> 2a) java.util. @Marker List
> 2b) @Marker java.util.List
In 2a we can simply attach the annotation on List.
In 2b we need to know whether java or util are the right class to attach to.
In the implementation, this changeset:
removes the ugly "onRightType" hack that was necessary to support the
So to me the approach of putting type annotations before the type's
simple name seems both more logical and easier to implement.
Please do let me know whether this makes sense or whether I should
elaborate more on some aspect.
I am also not quite sure what you mean with "It seems to go against
the 99% usage in the rest of the
spec." Could you elaborate on what your concerns are?
For an answer from the EG you probably need to re-send your message to
the spec-comments list.
More information about the type-annotations-dev