14.5. CONCLUSIONBytecode transformation is a powerful technique for modifying or adding new functionality to compiled Java classes, especially when performed at load time. The design and features of the Java classfile and the JVM, including the stack-oriented nature of the instructions, the use of symbolic references, and the class loading architecture, render bytecode a convenient and amenable target for late transformation. As implementations of extra features are concentrated at a single point, there are increased opportunities for code reuse. A single transformation may serve as the implementation of a feature for many different programs; improvements to that code result in improvements in all applications that use that transformation. This is a natural extension of the promise of object-oriented code. The programmatic nature of transformations and the ability of transformers to target individual instructions make bytecode transformation a powerful, albeit dangerous, tool. However, given a robust implementation with a layered interface that allows programmers to trade off protection and expressiveness, bytecode transformation is a useful and promising mechanism by which to apply new features and concerns into already compiled code. |