Here you can find the source of newInstance(Class> classZ)
public static Object newInstance(Class<?> classZ)
//package com.java2s; //License from project: Apache License import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.invoke.MethodHandles; public class Main { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public static Object newInstance(Class<?> classZ) { Object instance;/*from w w w . java2 s .co m*/ try { instance = classZ.newInstance(); } catch (InstantiationException | IllegalAccessException e) { logger.error("new instance failure", e); throw new RuntimeException(e); } return instance; } }