Logo Search packages:      
Sourcecode: jamvm version File versions

Class java::lang::ClassLoader::findClass ( String  name  )  throws ClassNotFoundException [inline, protected]

Called for every class name that is needed but has not yet been defined by this classloader or one of its parents. It is called by loadClass() after both findLoadedClass() and parent.loadClass() couldn't provide the requested class.

The default implementation throws a ClassNotFoundException. Subclasses should override this method. An implementation of this method in a subclass should get the class bytes of the class (if it can find them), if the package of the requested class doesn't exist it should define the package and finally it should call define the actual class. It does not have to resolve the class. It should look something like the following:

 // Get the bytes that describe the requested class
 byte[] classBytes = classLoaderSpecificWayToFindClassBytes(name);
 // Get the package name
 int lastDot = name.lastIndexOf('.');
 if (lastDot != -1)
     String packageName = name.substring(0, lastDot);
     // Look if the package already exists
     if (getPackage(pkg) == null)
         // define the package
         definePackage(packageName, ...);
 // Define and return the class
  return defineClass(name, classBytes, 0, classBytes.length);

loadClass() makes sure that the Class returned by findClass() will later be returned by findLoadedClass() when the same class name is requested.

name class name to find (including the package name)
the requested Class
ClassNotFoundException when the class can not be found

Definition at line 349 of file ClassLoader.java.

Referenced by loadClass().

    throw new ClassNotFoundException(name);

Generated by  Doxygen 1.6.0   Back to index