wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 38025
    
  22
ASM? That's hardly a beginner's topic. I shall try moving this to "advanced."
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: modify method in byte code using ASM.
 
Similar Threads
Static Variables Compilation
Overloading methods
instance variable
Method Overloading
Local Array