aspose file tools*
The moose likes Java in General and the fly likes modify method in byte code using ASM. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "modify method in byte code using ASM." Watch "modify method in byte code using ASM." New topic
Author

modify method in byte code using ASM.

jing hu
Ranch Hand

Joined: Jun 30, 2009
Posts: 63
For the class Test

Now I have the Test.class and have no source code.
I want to modify method f() like below.
add " int j = 10;" before " inti = 10;"


using ASM how to implement this.
Thank you very much.
Ashok Suthar
Ranch Hand

Joined: Apr 05, 2007
Posts: 30
Hi,

Extend the test Class and override its methods which you want to modify... If that fulfils your purpose.

I am not sure what you are trying to do here.


SCJP 5 (98%)...SCWCD On
jing hu
Ranch Hand

Joined: Jun 30, 2009
Posts: 63
I don't want to recompile this .class. recompiling the class may be hard work.
int my thread , the Test is just only a sample.
So I want to do some modification in the .class file. That is my main purpose.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
ASM? That's hardly a beginner's topic. I shall try moving this to "advanced."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modify method in byte code using ASM.