This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modify method in byte code using ASM.

 
jing hu
Ranch Hand
Posts: 63
  • 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
  • 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
  • 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
Posts: 48386
56
  • 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."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic