/** * Inspects a class and its superclasses (all the way to {@link Object} for method instances that contain a given * annotation. This even identifies private, package and protected methods, not just public ones. */ private static void inspectRecursively(Class<?> c, List<Method> s, Class<? extends Annotation> annotationType) { for (Method m : c.getDeclaredMethods()) { // don't bother if this method has already been overridden by a subclass if (notFound(m, s) && m.isAnnotationPresent(annotationType)) { s.add(m); } } if (!c.equals(Object.class)) { if (!c.isInterface()) { inspectRecursively(c.getSuperclass(), s, annotationType); } for (Class<?> ifc : c.getInterfaces()) inspectRecursively(ifc, s, annotationType); } }