Java Method Call invokePrivateMethod(Method method, Object object, Object... args)

Here you can find the source of invokePrivateMethod(Method method, Object object, Object... args)

Description

invoke Private Method

License

Open Source License

Declaration

public static Object invokePrivateMethod(Method method, Object object, 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 invokePrivateMethod(Method method, Object object, Object... args) { //Used to be private
        try {/*from ww w  . java  2s .  co m*/
            method.setAccessible(true);
            return method.invoke(object, args);
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            return null;
        } finally {
            method.setAccessible(false);
        }
    }
}

Related

  1. invokeParameterlessMethod(T theObject, String methodName)
  2. invokePrepare(Object instance)
  3. invokePrimivite(Object entity, Method writeMethod, Class propertyType, String propertyValue)
  4. invokePrivate(Class clazz, Object instance, String methodName, Class[] argTypes, Object[] args)
  5. invokePrivate(String name, final Object obj, Object[] objects)
  6. invokePrivateMethod(Object instance, String name, Object... args)
  7. invokePrivateMethod(Object obj, String methodName, Class[] parameterTypes, Object[] args)
  8. invokePrivateMethod(String methodName, Class clazz, Object object)
  9. invokeProperty(Object obj, String property)