for an annotation to be accessible at runtime it has to be annotated as follows
@Retention(RUNTIME)
How to access annotations
Method[] methods = cls.getMethods();
for(int i=0;i<methods.length';i++){
Annotation[] annos = methods[i].getAnnotations();
// the annos[] can be type casted to the annotation and then used.
}
No comments:
Post a Comment