Build 1.0_r1(from source)

java.lang
Class BootClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.lang.BootClassLoader

 class BootClassLoader
extends ClassLoader

Provides an explicit representation of the boot class loader. It sits at the head of the class loader chain and delegates requests to the VM's internal class loading mechanism.


Field Summary
(package private) static BootClassLoader instance
           
 
Constructor Summary
BootClassLoader()
           
 
Method Summary
protected  Class<?> findClass(String name)
          Overridden by subclasses, by default throws ClassNotFoundException.
protected  URL findResource(String name)
          Returns an URL which can be used to access the resource described by resName, using the class loader's resource lookup algorithm.
protected  Enumeration<URL> findResources(String resName)
          Returns an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm.
static BootClassLoader getInstance()
           
protected  Package getPackage(String name)
          Returns package information for the given package.
 
Methods inherited from class java.lang.ClassLoader
callerClassLoader, clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassAssertionStatus, getDefaultAssertionStatus, getPackage, getPackageAssertionStatus, getPackages, getParent, getResource, getResourceAsStream, getResources, getSigners, getStackClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, isAncestorOf, isSystemClassLoader, loadClass, loadClass, loadLibraryWithClassLoader, loadLibraryWithPath, 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

instance

static BootClassLoader instance
Constructor Detail

BootClassLoader

public BootClassLoader()
Method Detail

getInstance

public static BootClassLoader getInstance()

findClass

protected Class<?> findClass(String name)
                      throws ClassNotFoundException
Description copied from class: ClassLoader
Overridden by subclasses, by default throws ClassNotFoundException. This method is called by loadClass() after the parent ClassLoader has failed to find a loaded class of the same name.

Overrides:
findClass in class ClassLoader
Parameters:
name - The name of the class to search for.
Returns:
The class or null.
Throws:
ClassNotFoundException - if the class cannot be found.

findResource

protected URL findResource(String name)
Description copied from class: ClassLoader
Returns an URL which can be used to access the resource described by resName, using the class loader's resource lookup algorithm. The default behavior is just to return null. This should be implemented by a ClassLoader.

Overrides:
findResource in class ClassLoader
Parameters:
name - The name of the resource to find.
Returns:
The location of the resource.

findResources

protected Enumeration<URL> findResources(String resName)
                                  throws IOException
Description copied from class: ClassLoader
Returns an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm. The default behavior is just to return an empty Enumeration.

Overrides:
findResources in class ClassLoader
Parameters:
resName - The name of the resource to find.
Returns:
The locations of the resources.
Throws:
IOException - when an error occurs

getPackage

protected Package getPackage(String name)
Returns package information for the given package. Unfortunately, the BootClassLoader doesn't really have this information, and as a non-secure ClassLoader, it isn't even required to, according to the spec. Yet, we want to provide it, in order to make all those hopeful callers of myClass.getPackage().getName() happy. Thus we construct a Package object the first time it is being requested and fill most of the fields with dummy values. The Package object is then put into the ClassLoader's Package cache, so we see the same one next time. We don't create Package objects for null arguments or for the default package.

There a limited chance that we end up with multiple Package objects representing the same package: It can happen when when a package is scattered across different JAR files being loaded by different ClassLoaders. Rather unlikely, and given that this whole thing is more or less a workaround, probably not worth the effort.

Overrides:
getPackage in class ClassLoader
Parameters:
name - The name of the package to find
Returns:
The package requested, or null

Build 1.0_r1(from source)

Please submit a feedback, bug or feature