Last active
July 27, 2024 08:24
-
-
Save Maccimo/9d6244d61040c9401d2a35506b71df73 to your computer and use it in GitHub Desktop.
JSR/RET JVM instructions usage sample
This file contains 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
/** | |
* JSR/RET cannot be used in class files with version 51.0 or above but still supported by JVM for class file version 50.* and below. | |
*/ | |
super public class HelloJSR | |
version 50:0 | |
{ | |
public Method "<init>":"()V" | |
stack 1 locals 1 | |
{ | |
aload_0; | |
invokespecial Method java/lang/Object."<init>":"()V"; | |
return; | |
} | |
public static varargs Method main:"([Ljava/lang/String;)V" | |
stack 2 locals 2 | |
{ | |
jsr Hello; | |
jsr World; | |
return; | |
World: | |
astore_1; | |
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;"; | |
ldc String "world!"; | |
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V"; | |
ret 1; | |
Hello: | |
astore_1; | |
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;"; | |
ldc String "Hello, "; | |
invokevirtual Method java/io/PrintStream.print:"(Ljava/lang/String;)V"; | |
ret 1; | |
} | |
} // end Class HelloJSR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment