| public Class loadClass (final String name, final boolean resolve) throws ClassNotFoundException { if (TRACE) System.out.println ("loadClass (" + name + ", " + resolve + ")"); Class c = null; // First, check if this class has already been defined by this classloader // instance: c = findLoadedClass (name); if (c == null) { Class parentsVersion = null; try { // This is slightly unorthodox: do a trial load via the // parent loader and note whether the parent delegated or not; // what this accomplishes is proper delegation for all core // and extension classes without my having to filter on class name: parentsVersion = getParent ().loadClass (name); if (parentsVersion.getClassLoader () != getParent ()) c = parentsVersion; } catch (ClassNotFoundException ignore) {} catch (ClassFormatError ignore) {} if (c == null) { try { // OK, either 'c' was loaded by the system (not the bootstrap // or extension) loader (in which case I want to ignore that // definition) or the parent failed altogether; either way I // attempt to define my own version: c = findClass (name); } catch (ClassNotFoundException ignore) { // If that failed, fall back on the parent's version // [which could be null at this point]: c = parentsVersion; } } } if (c == null) throw new ClassNotFoundException (name); |