ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Introduction to the ASM 2.0 Bytecode Framework
Pages: 1, 2, 3, 4, 5, 6, 7, 8

There are several other changes introduced in ASM 2.0.

  • Introduced the new interfaces FieldVisitor and AnnotationVisitor.
  • CodeVisitor into MethodVisitor.
  • New visitCode() method added to the MethodVisitor to easily detect first instruction.
  • Constants interface renamed into Opcodes.
  • Almost all attributes from the attrs package are incorporated into ASM's event model.
  • TreeClassAdapter and TreeCodeAdapter are incorporated into the ClassNode and MethodNode.
  • Introduced the LabelNode class to make elements of instructions collection common type of AbstractInsnNode.

In general, it would be a good idea to run tool like JDiff and review the differences between the ASM 1.x and 2.0 APIs.

Conclusion

ASM 2.0 hides many bytecode complexities from the developer and allows one to efficiently work with Java features on a bytecode level. The framework allows you not only to transform and generate bytecode, but also to pull out significant details about existing classes. The API is being constantly improved--version 2.0 incorporates the generics and annotations introduced in J2SE 5.0. Since then, support for the new features introduced in Mustang (see "Java SE 6 Snapshot Releases") have been added to the ASM framework.

Resources

Eugene Kuleshov is an independent consultant with over 15 years of experience in software design and development.


Return to ONJava.com.