Java Method Call invokePrivateMethod(String methodName, Class clazz, Object object)

Here you can find the source of invokePrivateMethod(String methodName, Class clazz, Object object)

Description

invoke Private Method

License

Open Source License

Declaration

public static void invokePrivateMethod(String methodName, Class<?> clazz, Object object) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static void invokePrivateMethod(String methodName, Class<?> clazz, Object object) {
        try {/*from w w  w .ja  v  a2 s. c o m*/
            final Method method = clazz.getDeclaredMethod(methodName);

            method.setAccessible(true);

            method.invoke(object);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
    }
}

Related

  1. invokePrivate(Class clazz, Object instance, String methodName, Class[] argTypes, Object[] args)
  2. invokePrivate(String name, final Object obj, Object[] objects)
  3. invokePrivateMethod(Method method, Object object, Object... args)
  4. invokePrivateMethod(Object instance, String name, Object... args)
  5. invokePrivateMethod(Object obj, String methodName, Class[] parameterTypes, Object[] args)
  6. invokeProperty(Object obj, String property)
  7. invokeProtectedMethod(Class c, String method, Object... args)
  8. invokeProtectedMethod(Object o, Object[] args, String methodName, Class[] types)
  9. invokeProxied(final Callable callable, final ClassLoader classLoader)