File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modify method in byte code using ASM.

 
jing hu
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jing hu
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic