Bytecode Instrumentation
| 2004 JavaOne
SM
Conference | Session 3042 Copyright Hewlett Packard Co., 2004.
64
Dynamic BCI while program is running
Reset Constant Pool / Create class file
•
Monitoring thread periodically wakes up and calls:
─ MyAgent.update()
Select hot class-method to instrument
─ MyTransformer.mytransform()
Add method we want to call to the Constant Pool
– MyTransformer.traceMethod()
Modify the bytecode of the hot method
Update the max stack value
Reset the Constant Pool
Create new class file
inst.redefineClasses(class, bytecodes)