Java 2's ClassLoader Shortcut

Java 2 has made it somewhat easier to build a custom ClassLoader. With this release, the default implementation of loadClass still handles all of the obligatory steps, but it also calls a new method, findClass, to take care of any custom class loading.

This opens up an easy way to save yourself some trouble when writing a custom ClassLoader; simply override findClass instead of loadClass. By doing so, you eliminate the need to replicate the common steps that all loaders must perform—loadClass manages all of that.

Note that I'm not using this approach for my encrypting ClassLoader, however. The reason is simple. If the default ClassLoader looks for the encrypted classes first, it will find them—but because they're encrypted, they will be unrecognizable, and loading will fail. Thus, for our purposes we're forced to implement loadClass and take on some extra coding. —GT