O'Reilly logo

Component Development for the Java™ Platform by Stuart Dabbs Halloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.2. Custom Class Loaders

The rules for writing class loaders have changed over time, but the principle has remained basically the same. You implement a subclass of ClassLoader that knows, given a class name, how to create or find a byte array that is the class bytes for that class.

5.2.1. Pre-Java 2 Custom Class Loaders

Prior to SDK version 1.2, the relevant methods were loadClass, define-Class, and resolveClass, as shown in Listing 5-4. To implement a custom loader, you override the abstract method loadClass. Using the name argument, you find or create an array of bytes that has the correct binary class format, and then you pass these bytes to the defineClass method. ClassLoader's defineClass implementation then calls to native code inside ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required