Skip to content

Instantly share code, notes, and snippets.

@Maccimo
Last active March 8, 2022 02:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maccimo/9d6244d61040c9401d2a35506b71df73 to your computer and use it in GitHub Desktop.
Save Maccimo/9d6244d61040c9401d2a35506b71df73 to your computer and use it in GitHub Desktop.
JSR/RET JVM instructions usage sample
/**
* 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