Here you can find the source of getMethod(Class> clazz, String methodName, Class>... arguments)
Parameter | Description |
---|---|
clazz | a parameter |
methodName | a parameter |
arguments | a parameter |
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... arguments)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { /**// w w w. j a v a 2s .com * Fail-safe getMethod. * @param clazz * @param methodName * @param arguments * @return null in case of errors. */ public static Method getMethod(Class<?> clazz, String methodName, Class<?>... arguments) { try { return clazz.getMethod(methodName, arguments); } catch (NoSuchMethodException e) { } catch (SecurityException e) { } return null; } /** * Get a method matching one of the declared argument specifications. * @param clazz * @param methodName * @param argumentLists * @return The first matching method (given order). */ public static Method getMethod(Class<?> clazz, String methodName, Class<?>[]... argumentLists) { Method method = null; for (Class<?>[] arguments : argumentLists) { method = getMethod(clazz, methodName, arguments); if (method != null) { return method; } } return null; } }