Last active
April 19, 2024 05:02
-
-
Save bartekpacia/a8f8dc11c5ce3783c8568e7b3365b2b7 to your computer and use it in GitHub Desktop.
Example JMM files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
public int constInstr() { | |
return 0; | |
} | |
public int add(int a, int b) { | |
int c; | |
c = a + this.constInstr(); | |
return 0; | |
} | |
public int methodTwo() { | |
int a; | |
int b; | |
int c; | |
c = a + b; | |
return 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; class with syntax accepted by jasmin 2.3 | |
.class public Hello | |
.super java/lang/Object | |
; standard initializer | |
.method public <init>()V | |
aload_0 | |
invokenonvirtual java/lang/Object/<init>()V | |
return | |
.end method | |
.method public static foo(Ljava/lang/Object;)V | |
.limit stack 2 | |
return | |
.end method | |
.method public static main([Ljava/lang/String;)V | |
.limit stack 2 | |
;. limit locals 2 ; this example does not need local variables | |
getstatic java/lang/System.out Ljava/io/PrintStream; | |
ldc "Hello World!" | |
invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V | |
return | |
.end method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; class with syntax accepted by jasmin 2.3 | |
.class public HelloComplex | |
.super java/lang/Object | |
.field public static intField B | |
; 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 2 ; this example does not need local variables | |
ldc "" | |
invokestatic Test.foo(Ljava/lang/Object;)I | |
return | |
.end method | |
.method public static foo(Ljava/lang/Object;)I | |
.limit stack 99 | |
.limit locals 99 | |
; Doesn't work for some reason | |
; aload 0 ; -> objectref | |
; bipush 10 ; -> value | |
; putfield Test/intField B ; objectref, value → | |
bipush 10 ; -> value | |
putstatic Test/intField B ; value -> | |
; aload 0 ; -> objectref | |
; getfield Test.intField B ; objectref -> value | |
; istore 1 ; value -> | |
; iload 0 ; -> value | |
getstatic java/lang/System.out Ljava/io/PrintStream; | |
ldc "Hello World!" | |
invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V | |
bipush 0 | |
ireturn ; value -> | |
.end method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; class with syntax accepted by jasmin 2.3 | |
.class public Test | |
.super java/lang/Object | |
.field public static staticIntField B | |
.field public intField I | |
; 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 2 ; this example does not need local variables | |
ldc "" | |
invokestatic Test.foo(Ljava/lang/Object;)I | |
return | |
.end method | |
.method public static foo(Ljava/lang/Object;)I | |
.limit stack 99 | |
.limit locals 99 | |
; Doesn't work for some reason | |
; aload 0 ; -> objectref | |
; bipush 10 ; -> value | |
; putfield Test/intField B ; objectref, value → | |
putstatic Test/staticIntField B | |
; aload 0 ; -> objectref | |
; getfield Test.intField B ; objectref -> value | |
; istore 1 ; value -> | |
; iload 0 ; -> value | |
getstatic java/lang/System.out Ljava/io/PrintStream; | |
ldc "Hello World!" | |
invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V | |
ireturn ; value -> | |
.end method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment