Java Reflection Method Invoke invoke(Method method, Object object, Object... args)

Here you can find the source of invoke(Method method, Object object, Object... args)

Description

Invoke.

License

Open Source License

Parameter

Parameter Description
method the method
object the object
args the args

Exception

Parameter Description
Exception the exception

Return

the object

Declaration

private static Object invoke(Method method, Object object, Object... args) throws Exception 

Method Source Code

//package com.java2s;

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

public class Main {
    /**//from  www  .  j  av  a 2s  .co  m
     * Invoke.
     *
     * @param method the method
     * @param object the object
     * @param args the args
     * @return the object
     * @throws Exception the exception
     */
    private static Object invoke(Method method, Object object, Object... args) throws Exception { // NOPMD
        try {
            return method.invoke(object, args);
        } catch (final InvocationTargetException e) {
            if (e.getCause() instanceof Exception) {
                throw (Exception) e.getCause();
            } else if (e.getCause() instanceof Error) {
                throw (Error) e.getCause();
            } else {
                throw new Exception(e.getCause()); // NOPMD
            }
        }
    }
}

Related

  1. invoke(Method method, Object instance, Object... parameters)
  2. invoke(Method method, Object it, Object... args)
  3. invoke(Method method, Object javaBean, Object value)
  4. invoke(Method method, Object obj, Object... args)
  5. invoke(Method method, Object obj, Object... args)
  6. invoke(Method method, Object object, Object... arguments)
  7. invoke(Method method, Object object, Object... arguments)
  8. invoke(Method method, Object object, Object... parameters)
  9. invoke(Method method, Object object, Object[] args, Class exceptionToThrow)