Here you can find the source of getAnnotation(Method method, Class annotationType)
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class Main { public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) { A ann = method.getAnnotation(annotationType); if (ann == null) { for (Annotation metaAnn : method.getAnnotations()) { ann = metaAnn.annotationType().getAnnotation(annotationType); if (ann != null) { break; }/*from ww w . j a va 2 s .c om*/ } } return ann; } public static Annotation[] getAnnotations(Method method) { return method.getDeclaredAnnotations(); } }