开发者

Jasmin Assembler VerifyError : Expecting to find object/array on stack

I get this error after "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.

Code:

.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
  getsta开发者_如何学Pythontic java/lang/System/out Ljava/io/PrintStream;
  iload_1
  invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V

  return
.end method


You've got multiple issues.

First: you need to change the final

iload_1

to be

aload_1

  • you're loading the String array parameter, so shouldn't be using an integer load (iload) to do it.

Second, you're loading a String array, not a String. You need to choose which element you want. (look up aaload for how to dereference elements in the array.)

You need to fix both before it'll actually work.


This will work:

.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

Basically the change consists in the signature of System.out.println(int).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜