I try to play with reflection and annotations. For some reason, when I add annotation to a field (or class or method) and use reflection to view the field, I see that its annotations
field is null.
For example, this code:
public class Test { public static void main(String[] args) throws NoSuchFieldException, SecurityException { System.out.println(Test.class.getField("bl").getAnnotations().length); } @anno public int bl; public @interface anno {} }
prints 0.
By the way, Java does not ignore annotations at all, and when (for example) I use the @Deprecated
annotation - Eclipse recognizes it and says that the class is deprecated.
I am using the Eclipse Indigo update and Java SE Development Kit 7 2. Thank you!
source share