We’ll take a bottom up approach in this example, so we’ll
start with the
class loader. In 1.1, writing a class
loader means extending the
ClassLoader class and
loadClass( ) method to provide
the necessary semantics.
The implementation that we’ll use follows the same steps as we
listed in Chapter 6. However, some of those steps
rely on methods of the class loader that we haven’t yet
examined. In Java 2, these methods aren’t used because
they’re called automatically by the
loadClass( ) method; in 1.1, you’re responsible for calling the
Attempt to find the named class by using the internal class loader to
search the user’s classpath and the core JDK classes
(classes.zip). If the system class is not found,
ClassNotFoundException is generated. This
accomplishes a similar task as deferring to the parent class loader
does in Java 2 (although the Java 2 mechanism is much more flexible).
Find the class object for a class previously loaded by this class
loader. This method returns
null if it cannot
find the given class.
For a given class, resolve all the immediately needed class references for the class; this will result in recursively calling the class loader to ask it to load the referenced class.
In addition to implementing the
loadClass( ) method, we need our class loader to provide ...