Skip to content

Instantly share code, notes, and snippets.

@JarvisCraft
Created November 21, 2019 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarvisCraft/c2c0a20be22fbca52cdd1b26f37f3fed to your computer and use it in GitHub Desktop.
Save JarvisCraft/c2c0a20be22fbca52cdd1b26f37f3fed to your computer and use it in GitHub Desktop.
Java this and wut
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class Main {
public static void main(String[] args) {
Main main = new Main();
main.foo();
main.bar();
main.baz();
main.qux();
}
void foo() {
System.out.println("Foo");
}
void bar(Main this) {
System.out.println("Bar");
}
void baz(@SrcAnnotation Main this) {
System.out.println("Baz");
}
void qux(@RTAnnotation Main this) {
System.out.println("qux");
}
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@interface SrcAnnotation {}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@interface RTAnnotation {}
}
progrm_jarvis@PROgrm-JARvis:~/1$ javac Main.java && javap -c -v Main.class
Classfile /home/progrm_jarvis/1/Main.class
Last modified 21 нояб. 2019 г.; size 944 bytes
SHA-256 checksum 5c2d208eec4a8ba962612cfa2fef00c9084e72071c785261d44fb91240997e9e
Compiled from "Main.java"
public class Main
minor version: 0
major version: 57
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #7 // Main
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 6, attributes: 3
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Class #8 // Main
#8 = Utf8 Main
#9 = Methodref #7.#3 // Main."<init>":()V
#10 = Methodref #7.#11 // Main.foo:()V
#11 = NameAndType #12:#6 // foo:()V
#12 = Utf8 foo
#13 = Methodref #7.#14 // Main.bar:()V
#14 = NameAndType #15:#6 // bar:()V
#15 = Utf8 bar
#16 = Methodref #7.#17 // Main.baz:()V
#17 = NameAndType #18:#6 // baz:()V
#18 = Utf8 baz
#19 = Methodref #7.#20 // Main.qux:()V
#20 = NameAndType #21:#6 // qux:()V
#21 = Utf8 qux
#22 = Fieldref #23.#24 // java/lang/System.out:Ljava/io/PrintStream;
#23 = Class #25 // java/lang/System
#24 = NameAndType #26:#27 // out:Ljava/io/PrintStream;
#25 = Utf8 java/lang/System
#26 = Utf8 out
#27 = Utf8 Ljava/io/PrintStream;
#28 = String #29 // Foo
#29 = Utf8 Foo
#30 = Methodref #31.#32 // java/io/PrintStream.println:(Ljava/lang/String;)V
#31 = Class #33 // java/io/PrintStream
#32 = NameAndType #34:#35 // println:(Ljava/lang/String;)V
#33 = Utf8 java/io/PrintStream
#34 = Utf8 println
#35 = Utf8 (Ljava/lang/String;)V
#36 = String #37 // Bar
#37 = Utf8 Bar
#38 = String #39 // Baz
#39 = Utf8 Baz
#40 = String #21 // qux
#41 = Utf8 Code
#42 = Utf8 LineNumberTable
#43 = Utf8 main
#44 = Utf8 ([Ljava/lang/String;)V
#45 = Utf8 RuntimeInvisibleTypeAnnotations
#46 = Utf8 LMain$RTAnnotation;
#47 = Utf8 SourceFile
#48 = Utf8 Main.java
#49 = Utf8 NestMembers
#50 = Class #51 // Main$RTAnnotation
#51 = Utf8 Main$RTAnnotation
#52 = Class #53 // Main$SrcAnnotation
#53 = Utf8 Main$SrcAnnotation
#54 = Utf8 InnerClasses
#55 = Utf8 RTAnnotation
#56 = Utf8 SrcAnnotation
{
public Main();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 6: 0
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: new #7 // class Main
3: dup
4: invokespecial #9 // Method "<init>":()V
7: astore_1
8: aload_1
9: invokevirtual #10 // Method foo:()V
12: aload_1
13: invokevirtual #13 // Method bar:()V
16: aload_1
17: invokevirtual #16 // Method baz:()V
20: aload_1
21: invokevirtual #19 // Method qux:()V
24: return
LineNumberTable:
line 8: 0
line 9: 8
line 10: 12
line 11: 16
line 12: 20
line 13: 24
void foo();
descriptor: ()V
flags: (0x0000)
Code:
stack=2, locals=1, args_size=1
0: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #28 // String Foo
5: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 16: 0
line 17: 8
void bar();
descriptor: ()V
flags: (0x0000)
Code:
stack=2, locals=1, args_size=1
0: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #36 // String Bar
5: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 20: 0
line 21: 8
void baz();
descriptor: ()V
flags: (0x0000)
Code:
stack=2, locals=1, args_size=1
0: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #38 // String Baz
5: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 24: 0
line 25: 8
void qux();
descriptor: ()V
flags: (0x0000)
Code:
stack=2, locals=1, args_size=1
0: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #40 // String qux
5: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 28: 0
line 29: 8
RuntimeInvisibleTypeAnnotations:
0: #46(): METHOD_RECEIVER
Main$RTAnnotation
}
SourceFile: "Main.java"
NestMembers:
Main$RTAnnotation
Main$SrcAnnotation
InnerClasses:
static #55= #50 of #7; // RTAnnotation=class Main$RTAnnotation of class Main
static #56= #52 of #7; // SrcAnnotation=class Main$SrcAnnotation of class Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment