Created
October 25, 2016 11:21
-
-
Save jsyeo/3c76aa9b1235a355570680b0172b0b34 to your computer and use it in GitHub Desktop.
bridge method
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
import java.util.Arrays; | |
public class Main { | |
public static void main(String[] args) { | |
Visitor<Integer> intVisitor = new Visitor<Integer>() { | |
@Override | |
public Integer visitInt() { | |
System.out.println("LOL"); | |
return null; | |
} | |
@Override | |
public Integer visitFloat() { | |
System.out.println("HAHA"); | |
return null; | |
} | |
}; | |
} | |
interface Visitor<R> { | |
R visitInt(); | |
R visitFloat(); | |
} |
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
// class version 50.0 (50) | |
// access flags 0x30 | |
// signature Ljava/lang/Object;LVisitor<Ljava/lang/Integer;>; | |
// declaration: Main$3 implements Visitor<java.lang.Integer> | |
final class Main$3 implements Visitor { | |
// compiled from: Main.java | |
OUTERCLASS Main main ([Ljava/lang/String;)V | |
// access flags 0x8 | |
static INNERCLASS Main$3 null null | |
// access flags 0x0 | |
<init>()V | |
L0 | |
LINENUMBER 32 L0 | |
ALOAD 0 | |
INVOKESPECIAL java/lang/Object.<init> ()V | |
RETURN | |
L1 | |
LOCALVARIABLE this LMain$3; L0 L1 0 | |
MAXSTACK = 1 | |
MAXLOCALS = 1 | |
// access flags 0x1 | |
public visitInt()Ljava/lang/Integer; | |
L0 | |
LINENUMBER 35 L0 | |
GETSTATIC java/lang/System.out : Ljava/io/PrintStream; | |
LDC "LOL" | |
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | |
L1 | |
LINENUMBER 36 L1 | |
ACONST_NULL | |
ARETURN | |
L2 | |
LOCALVARIABLE this LMain$3; L0 L2 0 | |
MAXSTACK = 2 | |
MAXLOCALS = 1 | |
// access flags 0x1 | |
public visitFloat()Ljava/lang/Integer; | |
L0 | |
LINENUMBER 41 L0 | |
GETSTATIC java/lang/System.out : Ljava/io/PrintStream; | |
LDC "HAHA" | |
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | |
L1 | |
LINENUMBER 42 L1 | |
ACONST_NULL | |
ARETURN | |
L2 | |
LOCALVARIABLE this LMain$3; L0 L2 0 | |
MAXSTACK = 2 | |
MAXLOCALS = 1 | |
// access flags 0x1041 | |
public synthetic bridge visitFloat()Ljava/lang/Object; | |
L0 | |
LINENUMBER 32 L0 | |
ALOAD 0 | |
INVOKEVIRTUAL Main$3.visitFloat ()Ljava/lang/Integer; | |
ARETURN | |
L1 | |
LOCALVARIABLE this LMain$3; L0 L1 0 | |
MAXSTACK = 1 | |
MAXLOCALS = 1 | |
// access flags 0x1041 | |
public synthetic bridge visitInt()Ljava/lang/Object; | |
L0 | |
LINENUMBER 32 L0 | |
ALOAD 0 | |
INVOKEVIRTUAL Main$3.visitInt ()Ljava/lang/Integer; | |
ARETURN | |
L1 | |
LOCALVARIABLE this LMain$3; L0 L1 0 | |
MAXSTACK = 1 | |
MAXLOCALS = 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment