1

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?

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
jrey
  • 2,163
  • 1
  • 32
  • 48

1 Answers1

2

Try using AnnotationUtils class from Spring's core.

I think you'll get the annotation from parent's class as you need.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292