ClassPathLoader { public Class<?> forName(final String name) throws ClassNotFoundException { final boolean isTraceEnabled = logger.isTraceEnabled(); if (isTraceEnabled) { logger.trace("forName({})", name); } Class<?> clazz = forName(name, isTraceEnabled); if (clazz != null) return clazz; throw new ClassNotFoundException(name); } ClassPathLoader(boolean excludeTCCL);  ClassPathLoader(boolean excludeTCCL, File workingDir); static ClassPathLoader setLatestToDefault(File workingDir); JarDeployer getJarDeployer(); URL getResource(final String name); Class<?> forName(final String name); @Override String toString(); URL getResource(final Class<?> contextClass, final String name); InputStream getResourceAsStream(final String name); InputStream getResourceAsStream(final Class<?> contextClass, final String name); Enumeration<URL> getResources(final String name); ClassLoader asClassLoader(); static ClassPathLoader getLatest(); static ClassLoader getLatestAsClassLoader();  }
@Test public void testForName() throws Exception { System.out.println("\nStarting ClassPathLoaderTest#testForName"); String classToLoad = "org.apache.geode.internal.classpathloaderjunittest.DoesExist"; Class<?> clazz = ClassPathLoader.getLatest().forName(classToLoad); assertThat(clazz).isNotNull(); }
@Test public void testGeneratingClassLoader() throws Exception { System.out.println("\nStarting ClassPathLoaderTest#testGeneratingClassLoader"); ClassLoader gcl = new GeneratingClassLoader(); String classToLoad = "com.nowhere.TestGeneratingClassLoader"; Class<?> clazz = gcl.loadClass(classToLoad); assertThat(clazz).isNotNull(); assertThat(clazz.getName()).isEqualTo(classToLoad); Object obj = clazz.newInstance(); assertThat(obj.getClass().getName()).isEqualTo(clazz.getName()); assertThatThrownBy(() -> { Class.forName(classToLoad); }).isInstanceOf(ClassNotFoundException.class); Class<?> clazzForName = Class.forName(classToLoad, true, gcl); assertThat(clazzForName).isNotNull(); assertThat(clazzForName).isEqualTo(clazz); Object objForName = clazzForName.newInstance(); assertThat(objForName.getClass().getName()).isEqualTo(classToLoad); }