@Test public void testLoadClass() throws Exception { ClassBundle classBundle = new ClassBundle(JustForTesting.class.getName()); classBundle.setCodebase(System.getProperty("user.dir")+File.separator+ "target"+File.separator+ "test-classes"+File.separator); Class testClass = ClassBundleLoader.loadClass(classBundle); Assert.assertNotNull(testClass); }
public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getContextClassLoader); try { theClass = loadClass(cCL, bundle); } finally { AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> { currentThread.setContextClassLoader(cCL); return (null); }); } return theClass; }
ClassBundleLoader { public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getContextClassLoader); try { theClass = loadClass(cCL, bundle); } finally { AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> { currentThread.setContextClassLoader(cCL); return (null); }); } return theClass; } }
ClassBundleLoader { public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getContextClassLoader); try { theClass = loadClass(cCL, bundle); } finally { AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> { currentThread.setContextClassLoader(cCL); return (null); }); } return theClass; }  }
ClassBundleLoader { public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getContextClassLoader); try { theClass = loadClass(cCL, bundle); } finally { AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> { currentThread.setContextClassLoader(cCL); return (null); }); } return theClass; }  static Class<?> loadClass(ClassBundle bundle); static Class<?> loadClass(final ClassLoader parent, ClassBundle bundle); }
ClassBundleLoader { public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getContextClassLoader); try { theClass = loadClass(cCL, bundle); } finally { AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> { currentThread.setContextClassLoader(cCL); return (null); }); } return theClass; }  static Class<?> loadClass(ClassBundle bundle); static Class<?> loadClass(final ClassLoader parent, ClassBundle bundle);  }