views:

1144

answers:

4

I have a Java project and internally it is dependent on asm jar. Strangely, I don't even know why my project somehow is dependent on this library (might be brought in by maven as a transitive dependency)?

Can anyone help me know why some one needs asm jar?

Thanks in advance !

EDIT: Can you also mention for what purposes/use-cases one might need asm jar?

+1  A: 

What other dependencies does your project have ? I suspect one of the jars you've decided you require (e.g. Spring or Hibernate) itself requires asm.jar ?

Brian Agnew
Brian, i am using Spring heavily in my project.. But why does Spring need asm? Just curious...
peakit
I don't know, I confess. It may perform bytecode injection for aspects, but I would check up on that.
Brian Agnew
never mind ! still thanks for the pointers.
peakit
+2  A: 

Maven-2 requires asm.jar to compile and run the application.

Here for more information.

EDIT:

Due to the many possible usages of program analysis, generation and transfor- mation techniques, many tools to analyze, generate and transform programs have been implemented, for many languages, Java included. ASM is one of these tools for the Java language, designed for runtime – but also offline – class generation and transformation. The ASM1 library was therefore designed to work on compiled Java classes. It was also designed to be as fast and as small as possible. Being as fast as possible is important in order not to slow down too much the applications that use ASM at runtime, for dynamic class gener- ation or transformation. And being as small as possible is important in order to be used in memory constrained environments, and to avoid bloating the size of small applications or libraries using ASM. ASM is not the only tool for generating and transforming compiled Java classes, but it is one of the most recent and efficient. It can be downloaded from http://asm.objectweb.org. Its main advantages are the following: 1) It has a simple, well designed and modular API that is easy to use. 2) It is well documented and has an associated Eclipse plugin. 3) It provides support for the latest Java version, Java 6. 4) It is small, fast, and very robust. 5) Its large user community can provide support for new users. 6) Its open source license allows you to use it in almost any way you want.

Found from this pdf file. I am under the impression that along with Java EE 6 also came a built-in tool, ASM for class generation and transformation. The PDF gives you detail in greater depth about ASM.

Hope this helps.

Anthony Forloney
@aforloney, thats the dependency for maven-pmd plugin.. i am not using PMD..why we need asm then?
peakit
i found a pdf online, i added it to my post with a blurb, i hope this helps.
Anthony Forloney
Ahh.. as per @Andreas_D asm can be used for instrumenting the class files. @aforloney, may be thats why maven's PMD plugin needs.. wat say?
peakit
That could definitely be the case, I'm very unfamiliar with Maven so I don't know for sure
Anthony Forloney
+1  A: 

It is possible to use the dependency plugin for Maven to see which library has asm as a dependency.

Vincent Ramdhanie
thanks Vincent for suggesting !
peakit
+3  A: 

ASM is a bytecode manipulation framework (see this page for a nice introduction) and is used by many things performing... bytecode manipulation: frameworks using proxy generation and reflection (Spring, Hibernate, etc), mocking frameworks (EasyMock, JMock, etc), code analysis tools (PMD, Findbugs, etc). Actually, the ASM project maintains a list of users organized by category, check it out.

As mentioned by Vincent, if you are depending transitively on ASM, the dependency:tree goal or the dependency report (see the PMD and Findbugs links above for examples) can help to analyze the situation and to find out from where its coming from. But this won't take into account dependencies of maven plugins that you are using, only dependencies of your project.

Pascal Thivent