Here you can find the source of getConstructor(Class
private static <T> Constructor<T> getConstructor(Class<T> type, Class<?>[] parameterTypes) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Constructor; public class Main { private static <T> Constructor<T> getConstructor(Class<T> type, Class<?>[] parameterTypes) throws Exception { try {//w ww . j av a 2s . com return type.getConstructor(parameterTypes); } catch (NoSuchMethodException e1) { try { return type.getDeclaredConstructor(parameterTypes); } catch (NoSuchMethodException e2) { throw e2; } } } }