Here you can find the source of getMethod(Class extends Object> clz, String methodName, Class[] methodArgs)
clz
or any of its superclasses.
Parameter | Description |
---|---|
clz | - declaring class of the method |
methodName | - name of the method |
methodArgs | - method arguments |
Parameter | Description |
---|---|
NoSuchMethodException | an exception |
public static Method getMethod(Class<? extends Object> clz, String methodName, Class[] methodArgs) throws NoSuchMethodException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { /**//from w w w. j a va 2 s . c om * Gets method from class <code>clz</code> or any of its superclasses. If no method can be found * <code>NoSuchMethodException</code> is raised. * * @param clz - declaring class of the method * @param methodName - name of the method * @param methodArgs - method arguments * @return requested method * @throws NoSuchMethodException */ public static Method getMethod(Class<? extends Object> clz, String methodName, Class[] methodArgs) throws NoSuchMethodException { if (clz == null) throw new NoSuchMethodException(methodName + "(" + methodArgs + ") method does not exist "); try { return clz.getDeclaredMethod(methodName, methodArgs); } catch (NoSuchMethodException e) { return getMethod(clz.getSuperclass(), methodName, methodArgs); } } }