Here you can find the source of invokePrivate(Class> clazz, Object instance, String methodName, Class>[] argTypes, Object[] args)
public static Object invokePrivate(Class<?> clazz, Object instance, String methodName, Class<?>[] argTypes, Object[] args)
//package com.java2s; import java.lang.reflect.Method; public class Main { public static Object invokePrivate(Class<?> clazz, Object instance, String methodName, Class<?>[] argTypes, Object[] args) {// www.jav a2 s . c om try { Method method = clazz.getDeclaredMethod(methodName, argTypes); method.setAccessible(true); return method.invoke(instance, args); } catch (Exception e) { throw new RuntimeException(e); } } }