You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The receiver in anonymous classes cannot be annotated, as there is no
Java-source-level type for it.
This is a limitation of the Java syntax.
The JSR 308 specification (at
http://types.cs.washington.edu/jsr308/specification/java-annotation-design.html)
says:
"An anonymous class has no name for its innermost class, so it is not possible
to annotate the receiver of its constructor or methods. If you need to do so,
re-write the anonymous class into a named class and then use a receiver
parameter."
This is unfortunate in the case of tools that automatically infer facts about a
program -- the tool may infer properties that it has no way to communicate to a
programmer or to a downstream tool.
It would be nice if insert-annotations-to-source would insert annotations for
anonymous class receivers as a comment somewhere in the source code, for the
benefit of programmers. (No tool would process this, at least not yet.)
Original issue reported on code.google.com by [email protected] on 12 Sep 2013 at 4:06
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 12 Sep 2013 at 4:06The text was updated successfully, but these errors were encountered: