public static Method getMethod ( Class < ? > type , String methodName , Class < ? > ... parameterTypes ) { try { return type . getDeclaredMethod ( methodName , parameterTypes ) ; } catch ( NoSuchMethodException cause ) { if ( type . getSuperclass ( ) != null ) { return getMethod ( type . getSuperclass ( ) , methodName , parameterTypes ) ; } throw new MethodNotFoundException ( cause ) ; } }
Gets a Method object representing the named method on the specified class . This method will recursively search up the class hierarchy of the specified class until the Object class is reached . If the named method is found then a Method object representing the class method is returned otherwise a NoSuchMethodException is thrown .