Hello,
How can I replace a statement or expression ?
For example:
class Test {
public static int add(int a, int b) {
return a+b;
}
}
How can I replace the "return a+b;" with "return _add(a, b);" ?
And then add another method "public static int _add(int a, int b)".
Best regards,
Eric
Javassist does not provide direct support for doing that.
You must manipulate Java bytecode as you do with BCEL.
Or, you can use insertAfter() so that the result of a+b
will be discarded and return _add(a, b).