public static Method getOverriddenMethod ( Method method ) { Class < ? > declaringClass = method . getDeclaringClass ( ) ; Class < ? > superClass = declaringClass . getSuperclass ( ) ; Method result = null ; if ( superClass != null && ! ( superClass . equals ( Object . class ) ) ) { result = findMethod ( method , superClass ) ; } if ( result == null ) { for ( Class < ? > anInterface : declaringClass . getInterfaces ( ) ) { result = findMethod ( method , anInterface ) ; if ( result != null ) { return result ; } } } return result ; }
Returns overridden method from superclass if it exists . If method was not found returns null .