Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Bytecode Manipulation Library Suggestions

I'm looking for a well-maintained Java bytecode manipulation library with an intuitive API. There seem to be quite a lot of them out there. Any suggestions on which ones to try?

like image 809
Daniel Avatar asked Mar 28 '10 07:03

Daniel


People also ask

What is ASM jar used for?

It can be used to modify existing classes or to dynamically generate classes, directly in binary form. ASM provides some common bytecode transformations and analysis algorithms from which custom complex transformations and code analysis tools can be built.

What is ASM library?

The ASM library is a project of the OW2 consortium. It provides a simple API for decomposing, modifying, and recomposing binary Java classes (i.e. bytecode). The project was originally conceived and developed by Eric Bruneton.

What is bytecode manipulation?

Bytecode manipulation consists in modifying the classes - represented by bytecode - compiled by the Java compiler, at runtime. It is used extensively for instance by frameworks such as Spring (IoC) and Hibernate (ORM) to inject dynamic behaviour to Java objects at runtime.

What does ASM mean Java?

ASM simply stands for ASMifier tool.


1 Answers

The best answer to your question will be governed by your specific needs and objectives; if you can expand upon what you're trying to accomplish, I can perhaps offer a more tailored response.

In lieu of that, however, in my experience, ASM offers probably the best combination of maturity, flexibility, and ease-of-use:

  • It's under relatively active development: even though the latest release is from June 2009, developers are regularly making commits to their VCS.
  • It's already in wide use in a number of prominent Java products, such as AspectJ, Groovy, Cobertura, and many others, which promises a wide user-base and thus a wide community for support.
  • It's fairly thoroughly documented, and there are a number of tutorials, user guides, and reference documents available both from the OW2 Consortium and the community at large.

N.B. The comment @Yuri left below describes a situation I personally haven't yet encountered but that may potentially pose a significant obstacle. Keep his observation/experience in mind while evaluating the various bytecode manipulation libraries.

like image 94
RTBarnard Avatar answered Oct 13 '22 00:10

RTBarnard