@Test public void test() throws Exception { final ClassLoader tempCL = new TempClassLoader(this.getClass().getClassLoader()); Class<?> clazz; clazz = tempCL.loadClass(TempClassLoaderTest.class.getName()); assertSame(tempCL, clazz.getClassLoader()); clazz = tempCL.loadClass(javax.persistence.EntityManager.class.getName()); assertNotSame(tempCL, clazz.getClassLoader()); clazz = tempCL.loadClass(java.lang.String.class.getName()); assertNotSame(tempCL, clazz.getClassLoader()); clazz = tempCL.loadClass(SampleAnnotation.class.getName()); assertSame(tempCL, clazz.getClassLoader()); }
@Override public Class loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); }
TempClassLoader extends URLClassLoader { @Override public Class loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); } }
TempClassLoader extends URLClassLoader { @Override public Class loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); } TempClassLoader(final ClassLoader parent); }
TempClassLoader extends URLClassLoader { @Override public Class loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); } TempClassLoader(final ClassLoader parent); void skip(final Skip s); @Override Class loadClass(final String name); @Override URL getResource(final String name); URL getInternalResource(final String name); Enumeration<URL> getResources(final String name); }
TempClassLoader extends URLClassLoader { @Override public Class loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); } TempClassLoader(final ClassLoader parent); void skip(final Skip s); @Override Class loadClass(final String name); @Override URL getResource(final String name); URL getInternalResource(final String name); Enumeration<URL> getResources(final String name);  }