Here you can find the source of invokeReflectConstruct(String className, Object[] parameter, Class[] args)
public static Object invokeReflectConstruct(String className, Object[] parameter, Class[] args)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Constructor; public class Main { public static boolean isThrowable = true; public static Object invokeReflectConstruct(String className, Object[] parameter, Class[] args) { try {//from ww w . j a va 2 s .c om Class clazz = Class.forName(className); Constructor constructor = clazz.getDeclaredConstructor(args); constructor.setAccessible(true); return constructor.newInstance(parameter); } catch (Exception e) { e.printStackTrace(); } if (isThrowable) { throw new RuntimeException("invokeReflectConstruct error " + className + " parameter " + parameter); } return null; } }