我一直在尝试编写一些Java字节码并使用Jasmin进行汇编。Java字节码子程序 - 无法加载返回地址
我试图让我的周围子程序的头,我不知道为什么我跑我的程序时,得到如下错误信息:
>java -jar jasmin.jar test.j
Generated: test.class
>java test
Exception in thread "main" java.lang.VerifyError: (class: test,
method: main signature: ([Ljava/lang/String;)V)
Cannot load return address from register 0
Could not find the main class: test. Program will exit.
下面是test.j字节码:
.class public test
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 6
.limit locals 5
jsr a ;Jump to subroutine 'a', pushing return address on operand stack
return ;Exit the program
a:
astore_0 ;Store the return address in variable 0
aload_0 ;Save the address onto the stack as address will be overwritten in 'b'
jsr b ;Jump to subroutine 'b', pushing return address on operand stack
astore_0 ;Store the address that was on the stack back into variable 0
ret 0 ;Return to just after "jsr a"
b:
astore_0 ;Store return address in variable 0
ret 0 ;Return to address stored in 0 (ie back to just after the jump in 'a')
.end method
跳转到单个子程序时,我没有任何问题,但似乎跳转到子程序内的子程序时出现问题。
任何有识之士为什么这是失败的将不胜感激!
我不知道JVM的内部,但对正常的CPU “登记” $ 0始终为0,不能通过汇编/字节码设置。你确定这是可能的字节码? – halfdan
我很确定使用“注册”0是很好的。我已经尝试了使用1而不是0的上述程序,并且我得到了相同的错误,但是“注册”为1. – Jack
好吧,只是一个疯狂的猜测。 – halfdan