Here you can find the source of newInstance(final Object obj, final String clazz)
@SuppressWarnings("unchecked") public static <R> R newInstance(final Object obj, final String clazz) throws ClassNotFoundException, InstantiationException, IllegalAccessException
//package com.java2s; //License from project: Apache License public class Main { @SuppressWarnings("unchecked") public static <R> R newInstance(final Object obj, final String clazz) throws ClassNotFoundException, InstantiationException, IllegalAccessException { final Class<?> c = obj.getClass().getClassLoader().loadClass(clazz); return (R) c.newInstance(); }/*w w w . j a v a2s . c o m*/ }