public static Map < Method , Method > findManagedMethods ( Class < ? > clazz ) { Map < Method , Method > result = new HashMap <> ( ) ; // gather all publicly available methods // this returns everything, even if it's declared in a parent for ( Method method : clazz . getMethods ( ) ) { // skip methods that are used internally by the vm for implementing covariance, etc if ( method . isSynthetic ( ) || method . isBridge ( ) ) { continue ; } // look for annotations recursively in superclasses or interfaces Method managedMethod = findManagedMethod ( clazz , method . getName ( ) , method . getParameterTypes ( ) ) ; if ( managedMethod != null ) { result . put ( method , managedMethod ) ; } } return result ; }
Find methods that are tagged as managed somewhere in the hierarchy