Java Method Call invokeAccessableMethodWithArguments(Object instance, String method, Object... arguments)

Here you can find the source of invokeAccessableMethodWithArguments(Object instance, String method, Object... arguments)

Description

invoke Accessable Method With Arguments

License

Apache License

Declaration

public static void invokeAccessableMethodWithArguments(Object instance, String method, Object... arguments) 

Method Source Code

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

import java.lang.reflect.InvocationTargetException;

public class Main {
    public static void invokeAccessableMethodWithArguments(Object instance, String method, Object... arguments) {
        Class<?>[] classes = new Class[arguments.length];
        for (int x = 0; x < arguments.length; x++) {
            classes[x] = arguments[x].getClass();
        }/*w  ww  . j a va2  s . c  om*/
        try {
            instance.getClass().getMethod(method, classes).invoke(instance, arguments);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {
        }
    }
}

Related

  1. invoke(String methodName, Object obj)
  2. invoke(String methodName, Object object, Class[] argTypes, Object[] args)
  3. invoke(String methodName, Object target, Class targetClass, Object[] args)
  4. invoke(String name, Object object, Object... args)
  5. invoke_ex(Object obj, String method, Class[] params, Object[] args)
  6. invokeAndCastCollection(T returnType, Method m, Object obj, Object... args)
  7. invokeAnnotatedDeclaredMethod(Object obj, Class annotationType)
  8. invokeAnUnwrapException(final Method method, final Object[] args, final Object target)
  9. invokeCallback(String callbackName, String callbackParam)