public static boolean isCompatible ( Method method , Method intfMethod ) { if ( method == intfMethod ) return true ; if ( ! method . getName ( ) . equals ( intfMethod . getName ( ) ) ) return false ; if ( method . getParameterTypes ( ) . length != intfMethod . getParameterTypes ( ) . length ) return false ; for ( int i = 0 ; i < method . getParameterTypes ( ) . length ; i ++ ) { Class rootParam = method . getParameterTypes ( ) [ i ] ; Class intfParam = intfMethod . getParameterTypes ( ) [ i ] ; if ( ! intfParam . isAssignableFrom ( rootParam ) ) return false ; } return true ; }
See if the two methods are compatible that is they have the same relative signature