Here you can find the source of invokePrivateConstructor(Class
public static <T> void invokePrivateConstructor(Class<T> clazz) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class Main { public static <T> void invokePrivateConstructor(Class<T> clazz) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final Constructor<T> constructor = clazz.getDeclaredConstructor(); constructor.setAccessible(true); constructor.newInstance();// w w w.j ava 2s . co m } }