Java Reflection Method Invoke invokeMethodQuietly(Object receiver, Method method, Object... args)

Here you can find the source of invokeMethodQuietly(Object receiver, Method method, Object... args)

Description

invoke Method Quietly

License

Apache License

Declaration

public static Object invokeMethodQuietly(Object receiver, Method method, Object... args) 

Method Source Code

//package com.java2s;
/**/*from ww  w.  ja  v a2 s. c  om*/
 * Copyright 2010-present Facebook.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

public class Main {
    public static Object invokeMethodQuietly(Object receiver, Method method, Object... args) {
        try {
            return method.invoke(receiver, args);
        } catch (IllegalAccessException ex) {
            return null;
        } catch (InvocationTargetException ex) {
            return null;
        }
    }
}

Related

  1. invokeMethodNoArgs(Object target, String methodName)
  2. invokeMethodOfClass(Class target, Method method)
  3. invokeMethodOnLoader(ClassLoader cl, String methodName, Object... params)
  4. invokeMethodOnObject(Method method, Object objectToInvokeOn, Object[] args)
  5. invokeMethodOnObject(Object target, String methodName)
  6. invokeMethods(final Object target, final List methods)
  7. invokeMethodsWithAnnotation(final Class annotation, final Object instance, final Object... args)
  8. invokeMethodWithArray2(Object target, Method method, Object[] args)
  9. invokeMethodWithKnownParamTypes(Object object, String methodName, Class[] methodParamTypes, Object... args)