Java Reflection Method Invoke invoke(Method method, Object target, Object... arguments)

Here you can find the source of invoke(Method method, Object target, Object... arguments)

Description

Invoke a method of the provided target with the provided arguments.

License

Apache License

Parameter

Parameter Description
method a parameter
target a parameter
arguments a parameter

Exception

Parameter Description
RuntimeException an exception

Declaration

public static Object invoke(Method method, Object target, Object... arguments) throws RuntimeException 

Method Source Code


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

import java.lang.reflect.Method;

public class Main {
    /**/*  w  ww .  j  a  va2 s  .  co  m*/
     * Invoke a method of the provided target with the provided arguments. Wraps any exception in a {@link RuntimeException}
     * @param method
     * @param target
     * @param arguments
     * @return
     * @throws RuntimeException
     */
    public static Object invoke(Method method, Object target, Object... arguments) throws RuntimeException {
        try {
            return method.invoke(target, arguments);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. invoke(Method method, Object object, Object... arguments)
  2. invoke(Method method, Object object, Object... arguments)
  3. invoke(Method method, Object object, Object... parameters)
  4. invoke(Method method, Object object, Object[] args, Class exceptionToThrow)
  5. invoke(Method method, Object target, Object... args)
  6. invoke(Method method, T instance, Object... params)
  7. invoke(MethodHandle methodHandle, Object... params)
  8. invokeJdbcMethod(Method method, Object target)
  9. invokeJdbcMethod(Method method, Object target)