Java bytecode edit tool set

來源:互聯網
上載者:User

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.

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.