Logo Search packages:      
Sourcecode: jamvm version File versions

synchronized Class java::lang::ClassLoader::loadClass ( String  name,
boolean  resolve 
) throws ClassNotFoundException [inline, protected]

Load a class using this ClassLoader or its parent, possibly resolving it as well using resolveClass(). It first tries to find out if the class has already been loaded through this classloader by calling findLoadedClass(). Then it calls loadClass() on the parent classloader (or when there is no parent it uses the VM bootclassloader)). If the class is still not loaded it tries to create a new class by calling findClass(). Finally when resolve is true it also calls resolveClass() on the newly loaded class.

Subclasses should not override this method but should override findClass() which is called by this method.

Parameters:
name the fully qualified name of the class to load
resolve whether or not to resolve the class
Returns:
the loaded class
Exceptions:
ClassNotFoundException if the class cannot be found

Definition at line 275 of file ClassLoader.java.

References findClass(), findLoadedClass(), loadClass(), parent, and resolveClass().

  {
    // Have we already loaded this class?
    Class c = findLoadedClass(name);
    if (c != null)
      return c;

    // Can the class be loaded by a parent?
    try
      {
      if (parent == null)
        {
          c = VMClassLoader.loadClass(name, resolve);
          if (c != null)
            return c;
        }
      else
        {
          return parent.loadClass(name, resolve);
        }
      }
    catch (ClassNotFoundException e)
      {
      }
    // Still not found, we have to do it ourself.
    c = findClass(name);
    if (resolve)
      resolveClass(c);
    return c;
  }


Generated by  Doxygen 1.6.0   Back to index