Java Method Call invoke(Object object, String methodName, Class[] argTypes, Object... args)

Here you can find the source of invoke(Object object, String methodName, Class[] argTypes, Object... args)

Description

invoke

License

Open Source License

Declaration

public static Object invoke(Object object, String methodName, Class<?>[] argTypes, Object... args) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Object invoke(Object object, String methodName, Class<?>[] argTypes, Object... args) {
        try {//from ww  w . j a  v a  2  s .  c  o  m
            Method onLayout = object.getClass().getDeclaredMethod(methodName, argTypes);
            onLayout.setAccessible(true);
            return onLayout.invoke(object, args);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. invoke(Object object, Object[] args, String methodName)
  2. invoke(Object object, String function, Object... params)
  3. invoke(Object object, String function, String parameter)
  4. invoke(Object object, String method, Object... args)
  5. invoke(Object object, String methodName)
  6. invoke(Object object, String methodName, Class returnType, Object... parameters)
  7. invoke(Object object, String methodName, Object[] args)
  8. invoke(Object objToInvoke, Class classToInvoke, String method, Class[] argumentClasses, Object[] arguments)
  9. invoke(Object owner, String methodName)