Rewriting method calls within compiled Java classes
I want to replace calls to a given class with calls to anther class within a method body whilst parsing compiled class files... or put another way, is there a method of detecting usages of a given class in a method and replacing just that part of the method using something like javaassist . for example.. if I had the compiled version of class A { public int m() { int i = 2; B.multiply(i,i); return i; } } is there a method of detecting the use of B and then altering the code to perform class A { public int m() { int i = 2; C.divide(i,i); return i; } } I know the alternative would be to write a