Check out the new USENIX Web site. next up previous
Next: Load-time Reflection Up: The JOIE Environment Previous: The JOIE ClassLoader

Transformers and the ClassLoader

JOIE transformers are written in Java. This design choice offers three important benefits. First, transformers have access to the full power of the Java language, including procedures and variables, conditional logic, and arbitrary control flow. Second, Java vastly simplifies JOIE's design, as no special interpreter for transformers is needed. Finally, since the transformers are executed by the JVM, they are subject to the same safety checks as any Java program.

A JOIE transformer is simply a Java class implementing the interface joie.ClassTransformer. To install a transformer, the user installs a bootstrap wrapper that instantiates the JOIE ClassLoader and the desired transformer classes, and then registers the transformer objects with the ClassLoader. The wrapper then requests the ClassLoader to load the main class of the application to execute; the ClassLoader automatically invokes each registered transformer for each class subsequently loaded by the application. The current version of the JOIE ClassLoader rejects attempts to register new transformers once the first class is loaded. This effectively prevents untrusted application code from installing transformers. This issue is discussed in more detail in Section 7.2.

The core of each transformer is implemented in its transform(ClassInfo) method, which is invoked by the ClassLoader to apply the transformation. Multiple transformers can be chained together by passing the ClassInfo object for each target class to each transformer in sequence. The ClassLoader invokes the transformers in order of priorities specified at registration time. Within the method transform, transformers may call upon the JOIE toolkit routines for reflection, class modification, or bytecode modification, as described in the following subsections.

 

  table78


Table 2: Selected methods from JOIE API.



Geoff Alex Cohen
Tue Apr 28 14:31:49 EDT 1998