Tyler Gaona Tyler Gaona - 1 month ago 7
Java Question

How to print a long in jasmin?

I can print an integer in jasmin like so:

getstatic java/lang/System/out Ljava/io/PrintStream;
bipush 7
invokevirtual java/io/PrintStream/println(I)V

What would the argument to
be to print a long (64-bit integer)?

I have tried
invokevirtual java/io/PrintStream/println(L)V
but the assembler tells me that
is an illegal signature. (Note:
and a long are both on the stack when I try to call this method.)

Answer Source

I was previously having trouble with this as well. L is reserved for literal object names and can not be used to print longs. However, J can be used to print long (64 bit) values.

So, your code would just be:

getstatic java/lang/System/out Ljava/io/PrintStream; ldc2_w 7 invokevirtual java/io/PrintStream/println(J)V