1

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
  getstatic java/lang/System/out Ljava/io/PrintStream;
  iload_1
  invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V

  return
.end method
0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.