My Goal
To be able to detect when, at runtime, a comparison is made (or any other operation like, *, - , /, >, < ,...
This should be achieved to edit the bytecode of a class using Javassist or ow2 ASM
What must be achieved
This code
public class Test{
public void m(){
if(a>2){
//blablabla
}
}
}
Has to become
public class Test{
public void m(){
if(someExternalClass.greaterThan(a,2)){
//blalbla
}
}
}
The greaterThan will return exactly the same result as '>' but will also be used the save the amount of comparisons The external class will then be notified everytime a comparison has been made
Extra note
It has to be done everywhere there is an operation. So not only in if statements.
This means
int a = c+d;
must also become
int a = someExternalClass.add(c,d);
Do you have any suggestions on how I can achieve this with Javassist or other libraries.
I guess it'll have something to do with OpCodes like IFLT, IFGT