Here you can find the source of newInstance(Class interfaceDefinition, String className, ClassLoader classLoader)
@SuppressWarnings("unchecked") private static <I> I newInstance(Class<I> interfaceDefinition, String className, ClassLoader classLoader)
//package com.java2s; //License from project: Open Source License public class Main { @SuppressWarnings("unchecked") private static <I> I newInstance(Class<I> interfaceDefinition, String className, ClassLoader classLoader) { try {//w ww. j ava 2 s. c o m Class<I> spiClass; if (classLoader == null) { spiClass = (Class<I>) Class.forName(className); } else { spiClass = (Class<I>) classLoader.loadClass(className); } return spiClass.newInstance(); } catch (ClassNotFoundException x) { throw new java.lang.RuntimeException("Provider " + className + " not found", x); } catch (Exception ex) { throw new java.lang.RuntimeException("Provider " + className + " could not be instantiated: " + ex, ex); } } }