Here you can find the source of getMethod(Class klass, String methodName, Class[] parameterTypes)
Parameter | Description |
---|---|
klass | the class which method is searched in |
methodName | the method name |
parameterTypes | the method parameter types |
public static Method getMethod(Class klass, String methodName, Class[] parameterTypes)
//package com.java2s; import java.lang.reflect.Method; public class Main { /**//w w w.j a va 2 s . c o m * Returns the method object identified by the specified class, name and * paramater types. This method recursively check all the specified class * superclasses to find the method. Returns null if not found. * * @param klass the class which method is searched in * @param methodName the method name * @param parameterTypes the method parameter types * */ public static Method getMethod(Class klass, String methodName, Class[] parameterTypes) { try { return klass.getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { if (klass.equals(Object.class)) return null; return getMethod(klass.getSuperclass(), methodName, parameterTypes); } } }