AJC and AJ5 commands for the aspectj of Java Reverse Foundation

Source: Internet
Author: User

The ACJ command is a compiler for compiling Java files and AJ files, equivalent to the Eclipse compiler (ECJ) +ASPECTJ Runtime extension

The AJ5 command uses-javaagent:pathto/aspectjweaver.jar to load the ASPECTJ program on jdk1.5 to modify the bytecode.

These two commands can be replaced with Java commands and Javac, and our command for the above article is an example


Load-time Weaving (LTW) weaving at load time

Compile

Ajc-outjar Myjar.jar helloworld.javaajc-outjar myaspect.jar-outxml myaspect.aj-classpath "myjar.jar;%CLASSPATH%"

Run

Aj5-classpath "myaspect.jar;myjar.jar;%classpath%" HelloWorld


Command translation

If the Aspectjrt.jar has been set in the CLASSPATH environment variable,%aspectj_home%\lib\aspectjrt.jar can be omitted in-classpath;

Compile

Javac Helloworld.javajar cvf myjar.jar helloworld.classjava-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;% aspectj_home%\lib\aspectjtools.jar;%classpath% "Org.aspectj.tools.ajc.main-outxml Myaspect.aj-outjar MyAspect.jar

Run

Java-javaagent:%aspectj_home%\lib\aspectjweaver.jar-classpath "Myaspect.jar;myjar.jar;%aspectj_home%\lib\ aspectjrt.jar;%classpath% "HelloWorld


Compile-time Weaving compile-time weaving

Compile

Ajc-outjar Mytarget.jar Helloworld.java Myaspect.aj

Run

Aj5-classpath "mytarget.jar;%classpath%" HelloWorld

Command translation

Compile

Java-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;%aspectj_home%\lib\aspectjtools.jar;%classpath%" Org.aspectj.tools.ajc.main-outjar Mytarget.jar Helloworld.java Myaspect.aj

Run

Java-classpath "mytarget.jar;%aspectj_home%\lib\aspectjrt.jar;%classpath%" HelloWorld



Post-compile Weaving after the compile-time weaving

Compile

Ajc-outjar Myjar.jar helloworld.javaajc-inpath Myjar.jar Myaspect.aj-outjar Mytarget.jar

Run

Aj5-classpath "mytarget.jar;%classpath%" HelloWorld

Command translation

Compile

Javac Helloworld.javajar cvf myjar.jar helloworld.classjava-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;% aspectj_home%\lib\aspectjtools.jar;%classpath% "Org.aspectj.tools.ajc.main-inpath Myjar.jar Myaspect.aj-outjar Mytarget.jar

Run

Java-classpath "mytarget.jar;%aspectj_home%\lib\aspectjrt.jar;%classpath%" HelloWorld


The advantage of translating into Java commands is that you can weave directly to specify multiple -javaagent at Load-time weaving (LTW) load

Such as

JAVA-JAVAAGENT:ASPECTJWEAVER.JAR-JAVAAGENT:ZKMAGENT.JAR-CP Tracing.jar; Zkm.jar Com.zelix.ZKM



AJC and AJ5 commands for the aspectj of Java Reverse Foundation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.