Java Reflection Method Get from Object getMethod(Class aObject, String aMethod, Class... aParameterTypes)

Here you can find the source of getMethod(Class aObject, String aMethod, Class... aParameterTypes)

Description

get Method

License

LGPL

Declaration

public static Method getMethod(Class aObject, String aMethod,
            Class<?>... aParameterTypes) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(Class aObject, String aMethod,
            Class<?>... aParameterTypes) {
        Method rMethod = null;//w  ww  .j av  a 2 s .  c om
        try {
            rMethod = aObject.getMethod(aMethod, aParameterTypes);
            rMethod.setAccessible(true);
        } catch (Throwable e) {/*Do nothing*/
        }
        return rMethod;
    }

    public static Method getMethod(Object aObject, String aMethod,
            Class<?>... aParameterTypes) {
        Method rMethod = null;
        try {
            rMethod = aObject.getClass()
                    .getMethod(aMethod, aParameterTypes);
            rMethod.setAccessible(true);
        } catch (Throwable e) {/*Do nothing*/
        }
        return rMethod;
    }
}

Related

  1. getMethod(Class c, String methodName, Object... pa)
  2. getMethod(Class objectClass, String methodName, String argumentType)
  3. getMethod(Class type, String name, Object[] args)
  4. getMethod(Class clz, String methodName, Class[] methodArgs)