Here you can find the source of newInstance(Class
public static <T> T newInstance(Class<T> type)
//package com.java2s; //License from project: Apache License import java.lang.reflect.*; public class Main { public static <T> T newInstance(Class<T> type) { return newInstance(type, new Class<?>[0]); }/*from w w w . j ava 2 s.com*/ public static <T> T newInstance(Class<T> type, Class<?>[] parameterTypes, Object... parameterValues) { try { Constructor<T> constructor = type.getDeclaredConstructor(parameterTypes); constructor.setAccessible(true); return constructor.newInstance(parameterValues); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } }