jeudi 7 mai 2015

Annotation Reflection for Method overrided

How to I can get the Annotation Object for method that was overriden.

/* I created a custom annotation named AclIgnore, 
   and I have the next following piece of code: */

public class abstract Parent{
    @AclIgnore
    public abstract String getName();

}

public class Children extends Parent{
    @Override
    public String getName(){
          return "theChildren";
   }
}

   /*I want the AclIgnore of Parent.getName() but the next code returns null */
/*method is getName of the instance*/
AclIgnore aclIgnore = method.getAnnotation(AclIgnore.class);

My Question is: Is it possible to get the AclIgnore annotation from the parent class when I have a java.lang.reflect.Method instance referring to the child's method?





Aucun commentaire:

Enregistrer un commentaire