[JSR308] javac, com.sun.source.tree and annotation on types

Forax Rémi forax at univ-mlv.fr
Sat Feb 3 08:34:49 EST 2007


To enable tools like FindBugs etc. to use annotation on types, the javac 
AST need to be updated.

I think its interresting to know that variables (local vars, parameters 
and fields) are represented by the same class
so if we allow annotation on type of fields, we need to explicitly write 
code to dissalow it
on type of local variables.

Else, it seems that the chosen syntax is the prefix one so
annotation on variable can be split in two groups,
annotation on the variable and annotation on its type.

By example  in
@Local
class Test {
  @NonNull @Column(name="_NAME") String name;
}

Column is an annotation  on name and
NonNull is an annotation on its type.

It raises some interresting questions :
Is this separation done by the compiler or by a specific annotation 
processor ?
suppose an annotation declared using @Target() with two ElementTypes one
on field and the other on type. Is this legal ?
Is this annotation will appear in the two groups ?

my two cents,
Rémi


 





More information about the JSR308 mailing list