Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert annotation as comment when there is no source location for it #52

Open
GoogleCodeExporter opened this issue Jul 3, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants