Type annotation appears before the type’s simple name

Alex Buckley alex.buckley at oracle.com
Thu Dec 13 13:11:57 PST 2012


Werner, thanks for jumping in. As you say, any question about an EG 
decision should be sent to type-annotations-spec-comments.

Paul, see the type-annotations-spec-experts list in October and November 
for discussion of the issue.

The available lists are described at 
http://openjdk.java.net/projects/type-annotations/.

Alex

On 12/13/2012 12:06 PM, Werner Dietl wrote:
> Hi Paul,
>
> 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:
>
> http://mail.openjdk.java.net/pipermail/type-annotations-spec-experts/2012-October/000012.html
>
> 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
> annotation belongs.
> For non-static nested classes, all three of the following are possible:
>
> Outer. @A Inner
> @A Outer.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:
>
> http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/4e24226764cb
>
> removes the ugly "onRightType" hack that was necessary to support the
> previous syntax.
>
> 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.
>
> Thanks,
> cu, WMD.
>


More information about the type-annotations-dev mailing list