java.lang.class 字节码_Java字节码错误指令

我目前正在为自己的DSL编写字节码编译器.但是,当执行我用ASM构造的字节码时,我收到以下错误:

Exception in thread "main" java.lang.VerifyError: Bad instruction

Exception Details:

Location:

ForClass.doLoop()V @14: wide

Reason:

Error exists in the bytecode

Bytecode:

0x0000000: 043c b200 101b b600 161b 0460 3c1b c411

0x0000010: 03e8 a4ff f0b1

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)

at java.lang.Class.privateGetMethodRecursive(Class.java:3048)

at java.lang.Class.getMethod0(Class.java:3018)

at java.lang.Class.getMethod(Class.java:1784)

at Test3.main(Test3.java:28)

这些是执行的指令:

mv.visitVarInsn(ILOAD, 1);

mv.visitVarInsn(SIPUSH, 1000);

mv.visitJumpInsn(IF_ICMPLE, l1);

问题似乎是SIPUSH.如果我用BIPUSH,10替换指令,一切都按预期工作.我从字节码大纲得到的字节码使用SIPUSH没有问题,所以我做错了什么?

最佳答案 解决方案很简单,我使用了错误的方法:

请使用visitIntInsn(SIPUSH,1000),而不是使用visitVarInsn(SIPUSH,1000).

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值