ASM jar - Why my java project has a dependency on this?

巧了我就是萌 提交于 2021-01-20 18:12:41

问题


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:


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.




回答2:


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.




回答3:


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 ?




回答4:


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



来源:https://stackoverflow.com/questions/1798724/asm-jar-why-my-java-project-has-a-dependency-on-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!