My goal
To be able to detect when a comparison is being performed at runtime (or any other operation, for example, *, -, /,>, <, ...
This should be done to edit the class bytecode using Javassist or ow2 ASM
What must be achieved
This code
public class Test{ public void m(){ if(a>2){
Must become
public class Test{ public void m(){ if(someExternalClass.greaterThan(a,2)){
The larger the value will be returned in exactly the same way as the '>', it will also be used to save the number of comparisons. Then the outer class will be notified every time the comparison is made.
Additional note
This should be done wherever there is an operation. Thus, not only in if statements.
It means
int a = c+d;
should also become
int a = someExternalClass.add(c,d);
Do you have any suggestions on how I can achieve this using Javassist or other libraries.
I guess this will be related to OpCodes such as IFLT, IFGT
source share