[Soot-list] Declaring fields in jasmin

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sun Nov 23 13:39:00 EST 2008


On Sun, Nov 23, 2008 at 4:06 PM, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
> This version of Jasmin has not much to do with the version of Jasmin
> that Soot uses. Some time ago, Ondrej Lhotak once wrote me the
> following. (I assume he doesn't mind me quoting this here.)

wow, indeed, but I think they are close enougth ...

Now I am getting another error, but this time running:

C:\Programas\p-tools\fpjava>java helloworld
Exception in thread "main" java.lang.VerifyError: (class: helloworld, method: ma
in signature: ([Ljava/lang/String;)V) Unable to pop operand off an empty stack

And here is my jasmin file:

.class public helloworld
.super java/lang/Object
.field public static Str Ljava/lang/String;
.method public <init>()V
  aload_0
  invokespecial java/lang/Object/<init>()V
  return
.end method
.method public static main([Ljava/lang/String;)V
  .limit stack 5
  .limit locals 100
  ldc "Hello World" <-- stack has 1 item
  putfield helloworld/Str Ljava/lang/String; <- nothing in the stack
  getfield helloworld/Str Ljava/lang/String; <- 1 item in the stack
  getstatic java/lang/System/out Ljava/io/PrintStream; <- 2 items in the stack
  swap
  invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
  return
.end method

If you wonder why store a value just to load it, it's because I am
actually writing a compiler which uses Jasmin =)

The <- were added by my just now just to count the size of the stack,
they aren`t part of the asm. Acording to my count there is nothing
wrong ... any ideas?

thank you very much,
-- 
Felipe Monteiro de Carvalho


More information about the Soot-list mailing list