@Test public void testPackages() throws IllegalArgumentException, IOException, ClassNotFoundException { LoadedLibrary lib = LoadedJarLibrary .createFromJar("export/jars/i5.las2peer.classLoaders.testPackage1-1.0.jar"); ServiceClassLoader testee = new ServiceClassLoader(lib, null, new DefaultPolicy()); Class<?> cl = testee.loadClass("i5.las2peer.classLoaders.testPackage1.CounterClass", false); assertSame(testee, cl.getClassLoader()); assertNotNull(cl.getPackage()); assertEquals(cl.getPackage().getName(), "i5.las2peer.classLoaders.testPackage1"); }
@Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Logger.logLoading(this, name, null); Class<?> c = findLoadedClass(name); if (c == null && this.policy.canLoad(name)) { try { if (parent != null) { c = parent.loadClass(name); } else { c = getSystemClassLoader().loadClass(name); } } catch (ClassNotFoundException e) { } } if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { Logger.logLoading(this, name, false); throw e; } } if (resolve) { resolveClass(c); } Logger.logLoading(this, name, true); return c; }
ServiceClassLoader extends ClassLoader { @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Logger.logLoading(this, name, null); Class<?> c = findLoadedClass(name); if (c == null && this.policy.canLoad(name)) { try { if (parent != null) { c = parent.loadClass(name); } else { c = getSystemClassLoader().loadClass(name); } } catch (ClassNotFoundException e) { } } if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { Logger.logLoading(this, name, false); throw e; } } if (resolve) { resolveClass(c); } Logger.logLoading(this, name, true); return c; } }
ServiceClassLoader extends ClassLoader { @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Logger.logLoading(this, name, null); Class<?> c = findLoadedClass(name); if (c == null && this.policy.canLoad(name)) { try { if (parent != null) { c = parent.loadClass(name); } else { c = getSystemClassLoader().loadClass(name); } } catch (ClassNotFoundException e) { } } if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { Logger.logLoading(this, name, false); throw e; } } if (resolve) { resolveClass(c); } Logger.logLoading(this, name, true); return c; } ServiceClassLoader(LoadedLibrary lib, ClassLoader parent, ClassLoaderPolicy policy); }
ServiceClassLoader extends ClassLoader { @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Logger.logLoading(this, name, null); Class<?> c = findLoadedClass(name); if (c == null && this.policy.canLoad(name)) { try { if (parent != null) { c = parent.loadClass(name); } else { c = getSystemClassLoader().loadClass(name); } } catch (ClassNotFoundException e) { } } if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { Logger.logLoading(this, name, false); throw e; } } if (resolve) { resolveClass(c); } Logger.logLoading(this, name, true); return c; } ServiceClassLoader(LoadedLibrary lib, ClassLoader parent, ClassLoaderPolicy policy); LoadedLibrary getLibrary(); @Override URL getResource(String resourceName); }
ServiceClassLoader extends ClassLoader { @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Logger.logLoading(this, name, null); Class<?> c = findLoadedClass(name); if (c == null && this.policy.canLoad(name)) { try { if (parent != null) { c = parent.loadClass(name); } else { c = getSystemClassLoader().loadClass(name); } } catch (ClassNotFoundException e) { } } if (c == null) { try { c = findClass(name); } catch (ClassNotFoundException e) { Logger.logLoading(this, name, false); throw e; } } if (resolve) { resolveClass(c); } Logger.logLoading(this, name, true); return c; } ServiceClassLoader(LoadedLibrary lib, ClassLoader parent, ClassLoaderPolicy policy); LoadedLibrary getLibrary(); @Override URL getResource(String resourceName);  }