您的位置:首页 > 编程语言 > Java开发

Java bytecode edit tool set

2010-12-12 20:14 766 查看
There are 2 tool set combinations for java bytecode editing.

1. ASM + JASMIN
First use ASM to disassemble the bytecode class file to assemble file.(see command line under ASM folder)
Then use JASMIN language specification to rewrite this class file and then compile this class file.(see command line under Jasmin folder)
Specification: http://jasmin.sourceforge.net/instructions.html
Advantage:
These 2 tools are very update-to-date, less risk for class file format compatibility.
Disadvantage:
We'll have a lot of work to do for using these 2 tools.

2. Java ByteEdit for our manipulation: (JBE Editor)
Just run jbe.bat in JBE folder and use the GUI to do that.
jbe.bat
Advantage:
Easy to use, quick for test.
Disadvantage:
Not very update-to-date, we may have a risk for class file format compatibility issue.

----------------------------------------------------------------------------------------------------------------

Tool download URL and their documenation URL:

ASM: http://asm.ow2.org

JASMIN: http://jasmin.sourceforge.net/

JBE: http://jbe.sourceforge.net/



----------------------------------------------------------------------------------------------------------------

Simple introduction for each tool listed as above:

ASM:

-------------------

1. Feature description:(From Java class file to bytecode assembly language)
java -classpath "asm.jar;asm-util.jar;yourjar.jar" org.objectweb.asm.util.TraceClassVisitor org.domain.package.YourClass
or
java -classpath "asm.jar;asm-util.jar" org.objectweb.asm.util.TraceClassVisitor org/domain/package/YourClass.class

TOTAL EXAMPLE:
SET CP="E:/Resource/ASM/asm3.3lib/asm-3.3.jar;E:/Resource/ASM/asm3.3lib/asm-util-3.3.jar"
SET CP=%CP%;"E:/Resource/Test"
java -classpath %CP% org.objectweb.asm.util.TraceClassVisitor HelloWorld > HelloWorld.asm

2. You could get more on this project by looking into the following URL:
http://asm.ow2.org/doc/tutorial-asm-2.0.html

-----------------------------------------------------------------------------------------------------------------

JASMIN:

1.Usage: (From disasessmbly language to java bytecode)
Include the jar files under the lib directory and then run the following command line:
java -jar jasmin.jar examples/HelloWorld.j [Windows]
or
java -jar jasmin.jar examples/HelloWorld.j [Unix/MacOsX]

2. You could get more on this project by looking into the following URL:
http://en.wikipedia.org/wiki/Jasmin_(Java_assembler)#Invoking
http://jasmin.sourceforge.net/

-----------------------------------------------------------------------------------------------------------------

JBE:
1. Usage: (Change java bytecode in disassemble mode directly)
Just run jbe.bat in JBE folder and use the GUI to do that.

2. If you want to know more about JBE, please take a look of the following site:
http://jbe.sourceforge.net/

------------------------------------------------------------------------------------------------------------------



Actually we can use ASM to manipulate the java assemble code directly with some self-coding, here based on our experience, I would like to say, JBE is the best tool for us to use.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: