Here you can find the source of invokePrivateMethod(String methodName, Class> clazz, Object object)
public static void invokePrivateMethod(String methodName, Class<?> clazz, Object object)
//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; } } }