Java Method Call invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args)

Here you can find the source of invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args)

Description

invoke

License

Apache License

Declaration

public static Object invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args)
            throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
            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 {
    public static final Class[] EMPTY_CLASSES = new Class[0];
    public static final Object[] EMPTY_PARAMS = EMPTY_CLASSES;

    public static Object invoke(Object obj, String methodName, Class[] parameterTypes, Object[] args)
            throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
            InvocationTargetException {
        if (parameterTypes == null)
            parameterTypes = EMPTY_CLASSES;
        Method method = obj.getClass().getMethod(methodName, parameterTypes);
        if (args == null)
            args = EMPTY_PARAMS;//from w ww .j av  a2s . c  o m
        return method.invoke(obj, args);
    }
}

Related

  1. invoke(Object obj, String method, Object param, Object paramType)
  2. invoke(Object obj, String methodName)
  3. invoke(Object obj, String methodName, boolean newValue)
  4. invoke(Object obj, String methodName, Class argType, Object arg)
  5. invoke(Object obj, String methodName, Class clazz, Object newValue)
  6. invoke(Object obj, String methodName, Object... args)
  7. invoke(Object obj, String methodName, Object... params)
  8. invoke(Object obj, String methodName, Object[] params)
  9. invoke(Object obj, String name, Object... args)