Java Reflection Method Invoke invokeMethod(Object bean, Method method, Object[] args)

Here you can find the source of invokeMethod(Object bean, Method method, Object[] args)

Description

Invokes supplied method against the supplied bean

License

Open Source License

Parameter

Parameter Description
bean a parameter
method a parameter
args a parameter

Exception

Parameter Description
IllegalArgumentException an exception
IllegalAccessException an exception
InvocationTargetException an exception

Return

Object value returned by the method invokation

Declaration

public static Object invokeMethod(Object bean, Method method, Object[] args)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException 

Method Source Code


//package com.java2s;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    /**// w w  w .j a va  2  s  .c  om
     * Invokes supplied method against the supplied bean
     * 
     * @param bean
     * @param method
     * @param args
     * @return Object value returned by the method invokation
     * @throws IllegalArgumentException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public static Object invokeMethod(Object bean, Method method, Object[] args)
            throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        return method.invoke(bean, args);
    }
}

Related

  1. invokeMethod(Method method, Object target, Object[] args)
  2. invokeMethod(Method method, Object target, Object[] args)
  3. invokeMethod(Method method, Object theObject, Object[] args)
  4. invokeMethod(Method method, Object... arguments)
  5. invokeMethod(Object bean, Method method, Object... param)
  6. invokeMethod(Object caller, Object classInstance, String className, String methodName, String parameterClasses[], Object[] parameters)
  7. invokeMethod(Object caller, String methodName, Object[] params)
  8. invokeMethod(Object classInstance, Method method, Object... args)
  9. invokeMethod(Object cls, String methodName, Class paramClass, String paramValue)