I have the following Java class:
public class ArtClassInt {
public boolean foo(int x) {
if(x == 3956681)
return true;
else
return false;
}
public boolean boo(int x) {
if(x <= 952140568)
return true;
else
return false;
}
public boolean boo1(int x, int y) {
if(x <= y)
return true;
else
return false;
}
public boolean zoo(int x) {
if(x+1 < 1267)
return true;
else
return false;
}
}
When I complied it and got its bytecode, I got the following statements that correspond to the if-statements in the source code:
ArtClassInt.boo1(II)Z: I4 Branch 3 IF_ICMPGT L17 - true
ArtClassInt.boo1(II)Z: I4 Branch 3 IF_ICMPGT L17 - false
ArtClassInt.boo(I)Z: I4 Branch 2 IF_ICMPGT L10 - true
ArtClassInt.boo(I)Z: I4 Branch 2 IF_ICMPGT L10 - false
ArtClassInt.foo(I)Z: I4 Branch 1 IF_ICMPNE L3 - true
ArtClassInt.foo(I)Z: I4 Branch 1 IF_ICMPNE L3 - false
ArtClassInt.zoo(I)Z: I6 Branch 4 IF_ICMPGE L24 - true
ArtClassInt.zoo(I)Z: I6 Branch 4 IF_ICMPGE L24 - false
I am totally confused about the mnemonics (i.e., IF_ICMPGE, IF_ICMPNE, etc). By looking at the source code, I expect that:
- The if-statement in the
foomethod should beif_icmpeqnotIF_ICMPNE - The if-statement in the
booandboo1methods should beif_icmplenotIF_ICMPGT. - The one in
zoomethod should beif_icmpltnotIF_ICMPGE.
Can someone please explain the reason behind that?
if(x <= 952140568) return true; else ...you can just write this:return x <= 952140568. What you're doing is a common beginners mistake.