Here you can find the source of getMethod(Class> clazz, String methodName, Class>... parameterTypes)
Parameter | Description |
---|---|
clazz | a parameter |
methodName | a parameter |
parameterTypes | a parameter |
public static final Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
//package com.java2s; // SMSLib is distributed under the terms of the Apache License version 2.0 import java.lang.reflect.Method; public class Main { /**/*from www . j a v a 2 s . co m*/ * Get a method by reflection, and wrap all expected {@link Exception} as {@link RuntimeException}. * @param clazz * @param methodName * @param parameterTypes * @return the requested {@link Method} */ public static final Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) { try { Method method = clazz.getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); return method; } catch (NoSuchMethodException ex) { throw new IllegalStateException(ex); } } }