3

I'm writing some code where I want to use BCEL to substitute all calls to methods of SomeClass with calls to methods of SomeOtherClass.

Right now, from my understanding, I can do this by:

  1. iterating over the instruction list
  2. finding all invokevirtual, invokestatic or invokespecial instructions that reference SomeClass
  3. replace those with the appropriate invokeX that references SomeOtherClass

This requires me to rewrite a lot of calls tho, and I have to handle at least three different cases (invokevirtual, invokestatic and invokespecial calls). Instead, is it possible to do it by manipulating the constant pool and replacing all constants that point to SomeClass with SomeOtherClass? if so, how?

Gian Luca Scoccia
  • 725
  • 1
  • 8
  • 26

0 Answers0