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

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

Description

This just catches and wraps IllegalArgumentException.

License

Apache License

Declaration

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

Method Source Code


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

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    /** This just catches and wraps IllegalArgumentException. */
    public static Object invokeMethod(Method method, Object bean, Object[] values)
            throws IllegalAccessException, InvocationTargetException {
        try {/*from w  w  w .ja v  a 2 s .com*/

            return method.invoke(bean, values);

        } catch (IllegalArgumentException e) {

            //log.error("Method invocation failed.", e);
            throw new IllegalArgumentException("Cannot invoke " + method.getDeclaringClass().getName() + "."
                    + method.getName() + " - " + e.getMessage());

        }
    }
}

Related

  1. invokeMethod(Method inMethod, Object inObject, Object[] inArgs)
  2. invokeMethod(Method m, Object instance, Object[] args)
  3. invokeMethod(Method m, Object[] o)
  4. invokeMethod(Method meth, String str)
  5. invokeMethod(Method method, Class beanClass, Object element)
  6. invokeMethod(Method method, Object instance, Object... parameters)
  7. invokeMethod(Method method, Object object)
  8. invokeMethod(Method method, Object object, Object... args)
  9. invokeMethod(Method method, Object object, Object... arguments)