Here you can find the source of invokeConstructor(Class
public static <T> T invokeConstructor(Class<T> type, Object value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.*; public class Main { public static <T> T invokeConstructor(Class<T> type, Object value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { return invokeConstructor(type, value, value.getClass()); }// ww w . j a v a 2s . c o m public static <T> T invokeConstructor(Class<T> type, Object value, Class<?> objectType) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Constructor<T> constructor = type.getConstructor(objectType); return constructor.newInstance(value); } }