Java Reflection Method Get from Object getMethod(Object obj, Class[] paramTypes, String methodName)

Here you can find the source of getMethod(Object obj, Class[] paramTypes, String methodName)

Description

Get the method given in string in input corresponding to the given arguments.

License

Apache License

Parameter

Parameter Description
obj Class in which the method is.
paramTypes types of the arguments.
methodName the name of the method.

Exception

Parameter Description
NoSuchMethodException an exception

Return

Methood

Declaration

@SuppressWarnings("rawtypes")
public static Method getMethod(Object obj, Class[] paramTypes, String methodName) throws NoSuchMethodException 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    /**/*from  w w  w.jav a 2 s .c  om*/
     * Get the method given in string in input corresponding to the given
     * arguments.
     * 
     * @param obj
     *            Class in which the method is.
     * @param paramTypes
     *            types of the arguments.
     * @param methodName
     *            the name of the method.
     * @return Methood
     * 
     * @throws NoSuchMethodException
     */
    @SuppressWarnings("rawtypes")
    public static Method getMethod(Object obj, Class[] paramTypes, String methodName) throws NoSuchMethodException {
        Method method = obj.getClass().getMethod(methodName, paramTypes);
        return method;
    }
}

Related

  1. getMethod(Object instance, String methodName, Class... argsClass)
  2. getMethod(Object instance, String methodName, Class[] parameters)
  3. getMethod(Object o, String methodName)
  4. getMethod(Object o, String methodName, Class[] args)
  5. getMethod(Object o, String methodName, Class[] paramTypes)
  6. getMethod(Object obj, String fieldName)
  7. getMethod(Object obj, String methodName)
  8. getMethod(Object obj, String methodName, Class paramClass)
  9. getMethod(Object obj, String methodName, Class... parameterTypes)