我在“java testphase”之后得到了这个错误:
C:\jasmin-2.4>java testphase
Exception in thread "main" java.lang.VerifyError:
(class: testphase, method: main signature: ([Ljava/lang/String;)V)
Expecting to find object/array on stack
Could not find the main class: testphase.
Program will exit.
代码:
.class public testphase
.super java/lang/Object
; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 10
.limit locals 3
; assign something
iconst_1
iconst_1
iadd
istore_1
; assign something
iconst_2
iconst_2
isub
istore_2
; Writeln
getstatic java/lang/System/out Ljava/io/PrintStream;
iload_1
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
答案 0 :(得分:1)
你有多个问题。
首先:你需要改变最后的
iload_1
是
aload_1
其次,您正在加载String数组,而不是String。您需要选择所需的元素。 (查看aaload,了解如何取消引用数组中的元素。)
你需要在实际工作之前解决这两个问题。
答案 1 :(得分:0)
这将有效:
.class public testphase
.super java/lang/Object
; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 3
; assign something
iconst_1
iconst_1
iadd
istore_1
; assign something
iconst_2
iconst_2
isub
istore_2
; Writeln
getstatic java/lang/System/out Ljava/io/PrintStream;
iload_1
invokevirtual java/io/PrintStream/println(I)V
; Writeln variable 2
getstatic java/lang/System/out Ljava/io/PrintStream;
iload_2
invokevirtual java/io/PrintStream/println(I)V
return
.end method
基本上,更改包含System.out.println(int)
的签名。