Java Reflection Method Parameter getMethod(Class clazz, String methodName, Class... parameterTypes)

Here you can find the source of getMethod(Class clazz, String methodName, Class... parameterTypes)

Description

Get a method by reflection, and wrap all expected Exception as RuntimeException .

License

Apache License

Parameter

Parameter Description
clazz a parameter
methodName a parameter
parameterTypes a parameter

Return

the requested

Declaration

public static final Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) 

Method Source Code

//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);
        }
    }
}

Related

  1. getMethod(Class c, String methodName, Class... parameterTypes)
  2. getMethod(Class clazz, String functionName, Class[] parameterTypes)
  3. getMethod(Class clazz, String method, Class... parameterTypes)
  4. getMethod(Class clazz, String methodName, Class... parameterTypes)
  5. getMethod(Class clazz, String methodName, Class... parameterTypes)
  6. getMethod(Class clazz, String name, Class... parameterTypes)
  7. getMethod(Class clazz, String name, Class... parameterTypes)
  8. getMethod(Class clazz, String name, Class[] parameterTypes)
  9. getMethod(Class cls, String name, Class... parameterTypes)