java instraction_Java bytecode instruction of if-statements

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 foo method should be if_icmpeq not IF_ICMPNE

The if-statement in the boo and boo1 methods should be if_icmple not IF_ICMPGT.

The one in zoo method should be if_icmplt not IF_ICMPGE.

Can someone please explain the reason behind that?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值