Bytecode Instrumentation
| 2004 JavaOne
SM
Conference | Session 3042 Copyright Hewlett Packard Co., 2004.
11
Parsing the Class File
•
Goal: Rapid parsing and low memory usage
•
Methods:
─ Ad hoc
─ Intermediate representation (IR)
─ Abstraction of class file elements
─ All elements as objects: BCEL
– Fly weight constants for immutables (stack ops)
─ Lightweight alternatives
– Visitor pattern for simple transformations: ASM
•
Must provide good public interface for chosen
audiences
─ BCEL targets bytecode experts
─ Javassist targets Java programmers