[Jsr308-statements] annotations on code blocks
Michael Ernst
mernst at csail.mit.edu
Sat Feb 3 09:49:36 EST 2007
> Perhaps Michael can elaborate little
> more on the reasons why method receivers annotation should be
> distinguished from annotations on the method itself, but it look like this:
>
> public int size() @Readonly { ... }
An annotation before the method declaration annotates either the return
type, or the method declaration. You can tell the annotation target by
looking at the annotation which it is, as in
@Deprecated
@NonNull Dimension getSize foo() { ... }
where @Deprecated applies to the method and @NonNull applies to the return
type.
An annotation after the parameter list applies to the receiver ("this").
For example,
Dimension getSize() @Readonly { ... }
indicates that getSize does not modify its receiver. (That's different
than saying the method has no side effects at all, so it isn't appropriate
as a method annotation.)
Does this make sense?
-Mike
PS: This is now getting a bit off-topic for jsr308-statements mailing
list, but the discussion did start on-topic.
More information about the Jsr308-statements
mailing list