I have this jasmin assembly, which is the equivalent of the simplification of JVM assembly produced by a bytecode rewriter I am writing. It crashes when run, but works if I remove the sipush
and the first store.
.method public simple()V
.limit stack 4
sipush 12345
istore_1
getstatic java/lang/System/out Ljava/io/PrintStream;
sipush 12345
ldc 12345
iadd
invokevirtual java/io/PrintStream/println(I)V
return
.end method
Does the JVM require every store to be used by a load?
istore_1
stores a value to the local variable #1, but your methods has no locals.
The method will become valid if you add the following line:
.limit locals 2