コード例 #1
0
 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;
 }
コード例 #2
0
 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.");
   }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 public void add(TestFailure failure) {
   _failures.add(failure);
 }
コード例 #5
0
 /** @sharpen.property Count */
 public int size() {
   return _failures.size();
 }
コード例 #6
0
 public Iterator4 iterator() {
   return _failures.iterator();
 }