Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

mijava
Class ClassLoader  view ClassLoader download ClassLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bymijava.ClassLoader

class ClassLoader
extends java.lang.ClassLoader


Nested Class Summary
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
private static java.lang.String _ID_
           
private  java.util.List classPath
           
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
(package private) ClassLoader()
           
 
Method Summary
protected  java.lang.Class findClass(java.lang.String name)
          Called for every class name that is needed but has not yet been defined by this classloader or one of its parents.
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Load a class using this ClassLoader or its parent, possibly resolving it as well using resolveClass().
protected  void prependToClassPath(java.lang.String path)
           
private static byte[] readArchive(java.io.File archive, java.lang.String fileName)
           
protected  void setClassPath(java.lang.String classPath)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classPath

private java.util.List classPath

_ID_

private static final java.lang.String _ID_
See Also:
Constant Field Values
Constructor Detail

ClassLoader

ClassLoader()
Method Detail

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Description copied from class: java.lang.ClassLoader
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.


findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Description copied from class: java.lang.ClassLoader
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(packageName) == 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.


setClassPath

protected void setClassPath(java.lang.String classPath)

prependToClassPath

protected void prependToClassPath(java.lang.String path)

readArchive

private static final byte[] readArchive(java.io.File archive,
                                        java.lang.String fileName)
                                 throws java.io.IOException