When using the Java reflections library I can correctly find classes decorated with an annotation:
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(CommandName.class);
but when I try to see how many annotations are on each class I always see zero:
for(Class c : annotated)
{
int numAnnotations = c.getAnnotations().length;
}
Why does c.getAnnotations()
return an array of length 0? In fact, in the debugger, all the fields (except name
) of c
are null
.