how to add if instruction before an if instruction by bcel

235 Views Asked by At

I want to use BCEL to add/insert some if_instruction before a specific if_instruction which is in my method.

Here is my method:

public void printMax(int x , int y){
  int max=x;
  //////here is my desire position//////////
  if(y>x)
    max=y;
  System.out.println(max);
}
1

There are 1 best solutions below

2
On

To me the if(x<y != y>x) is the same as if(false) so it would not succeed; so maybe you should use IF_ACMPNE, but I don't know BCEL ...