Here you can find the source of getMethodsAnnotatedWith(final Class> type, final Class extends Annotation> annotation)
public static List<Method> getMethodsAnnotatedWith(final Class<?> type, final Class<? extends Annotation> annotation)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static List<Method> getMethodsAnnotatedWith(final Class<?> type, final Class<? extends Annotation> annotation) { final List<Method> methods = new ArrayList<Method>(); Class<?> klass = type; while (klass != Object.class) { final List<Method> allMethods = new ArrayList<Method>( Arrays.asList(klass.getDeclaredMethods())); for (final Method method : allMethods) { if (annotation == null || method.isAnnotationPresent(annotation)) { Annotation annotInstance = method .getAnnotation(annotation); methods.add(method); }//from ww w . ja v a 2 s . co m } klass = klass.getSuperclass(); } return methods; } }