private static Collection4 collectNames(Class[] classes) { Collection4 names = new Collection4(); for (int classIdx = 0; classIdx < classes.length; classIdx++) { names.add(classes[classIdx].getName()); } return names; }
public static void main(String[] args) throws Exception { ClassLoader parent = ExcludingClassLoader.class.getClassLoader(); String excName = ExcludingClassLoader.class.getName(); Collection4 excluded = new Collection4(); ClassLoader incLoader = new ExcludingClassLoader(parent, excluded); System.out.println(incLoader.loadClass(excName)); excluded.add(excName); try { System.out.println(incLoader.loadClass(excName)); } catch (ClassNotFoundException exc) { System.out.println("Ok, not found."); } }
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { if (_excludedNames.contains(name)) { print("EXCLUDED: " + name); throw new ClassNotFoundException(name); } if (_cache.containsKey(name)) { print("CACHED: " + name); return (Class) _cache.get(name); } if (mustDelegate(name)) { print("NATIVE: " + name); return super.loadClass(name, resolve); } Class clazz = findRawClass(name); if (resolve) { resolveClass(clazz); } _cache.put(clazz.getName(), clazz); print("LOADED: " + name); return clazz; }
public void add(TestFailure failure) { _failures.add(failure); }
/** @sharpen.property Count */ public int size() { return _failures.size(); }
public Iterator4 iterator() { return _failures.iterator(); }