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

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

Description

invoke Silent

License

Apache License

Declaration

public static Object invokeSilent(Object obj, String methodName, Class[] parameterTypes, Object[] args) 

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 invokeSilent(Object obj, String methodName, Class[] parameterTypes, Object[] args) {
        try {/*from   ww  w .  ja v a2 s  .co m*/
            return invoke(obj, methodName, parameterTypes, args);
        } catch (Exception e) {
            // ignore
            return null;
        }
    }

    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;
        return method.invoke(obj, args);
    }
}

Related

  1. invokeRemoteMBeanOperation(String remoteURL, String jmxName, Class klass, Function function)
  2. invokeRestrictedMethod(Object obj, Class theClass, String methodName)
  3. invokeServiceClass(JsonReader jsonReader, Object service, Method operation, Class[] paramClasses, int paramCount)
  4. invokeSet(Object o, String fieldName, Object value)
  5. invokeSetFieldValue(Object bean, Field field, Object value)
  6. invokeSimple(Object target, String name)
  7. invokeTarget(Method method, Object obj, Object... args)
  8. invokeTargetCheckPoint(String resuming_checkpoint_path, Object jobObject, final java.util.Map globalMap)
  9. invokeTargetMethods(Object obj, T data, List methods)