- BCEL supports load-time reflection. Run-time reflection is built into Java via the Reflection API, load-time reflection allows you to modify the bytecode instruction set at the time of loading the class. How does this differ from a custom classloader? Well, you still need to write a custom class loader, which instead of passing bytecode directly to JVM, first passes it through your run-time system using BCEL API.
- It has a Static API to map structures described in the JVM specification. It also has a Generic API to create and transform class files dynamically, its heart is the ClassGen class, which allows you to create new class files, and add methods and attributes dynamically.
- Comes with a bytecode verifier called JustIce.
- Comes with a Class2HTML utility to generate html bytecode documentation for classfiles. This is interesting to see e.g. how synchronized code is implemented at the bytecode level.
So, if you want to write some bytecode manipulation programs, don't do it from scratch, but use BCEL as a basis!
No comments:
Post a Comment