### Question:
ReloadClassLoader extends ClassLoader { public static ReloadClassLoader newClassloader(URL... urls) { instance = new ReloadClassLoader(urls); return instance; } private  ReloadClassLoader(URL[] urls); URL[] getClasspathURLs(); void addClasspathURL(URL url); synchronized void reload(); static ReloadClassLoader newClassloader(URL... urls); static ReloadClassLoader currentClassLoader();  }### Answer:
@Test public void testLoadClass() throws Exception { File sourceFile = new File(reloadSourceDir); ReloadClassLoader cloader = ReloadClassLoader.newClassloader(new URL[]{sourceFile.toURL()}); Class clazz = cloader.loadClass(reloadClassName); Class objectClazz = cloader.loadClass("java.lang.Math"); assertTrue(clazz != null); assertTrue(objectClazz != null); assertEquals(Math.class, objectClazz); }
@Test public void testLoadClassPerformance() throws Exception { File sourceFile = new File(reloadSourceDir); ReloadClassLoader cloader = ReloadClassLoader.newClassloader(new URL[]{sourceFile.toURL()}); for ( int i=0; i<1000; i++ ) { Class clazz = cloader.loadClass(reloadClassName); Class objectClazz = cloader.loadClass("java.lang.Math"); } }
@Test public void testEmptyPath() throws Exception { ReloadClassLoader cloader = ReloadClassLoader.newClassloader( new URL[]{ new URL("file: new URL("file: } ); }
@Test public void testLoadParentClass() throws Exception { File sourceDir = new File(reloadSourceDir); ReloadClassLoader cloader = ReloadClassLoader.newClassloader(new URL[]{sourceDir.toURL()}); Class clazz = cloader.loadClass("com.google.protobuf.GeneratedMessage"); assertTrue(clazz != null); }