???????????????
????18: invokevirtual #6 // Method TestMain$Caller.call:(Ljava/lang/String;)V
????????????????????????????????String?????????????caller??????
??????д?????????
public class TestMain {
public static void main(String[] args) {
String str = new String();
Caller caller = new SubCaller();
caller.call(str);
}
static class Caller {
public void call(String str) {
System.out.println("a String instance in Caller");
}
}
static class SubCaller extends Caller {
@Override
public void call(String str) {
System.out.println("a String instance in SubCaller");
}
}
}
??????е????
????22:27 $ java TestMain
????a String instance in SubCaller
????????????Caller???????call??????????SubCaller???Caller????????д??call???????????????????????Caller????????callerSub?????????????????????SubCaller???????????????????????????SubCaller??call????????????Caller??call?????????????????????????????????????????????????????????????????????汾??call????????
???????
???????javap????????????????????????????н??о????????????????????????
22:27 $ javap -c TestMain
Compiled from "TestMain.java"
public class TestMain {
public TestMain();
Code:
0: aload_0
1: invokespecial #1                  // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: new           #2                  // class java/lang/String
3: dup
4: invokespecial #3                  // Method java/lang/String."<init>":()V
7: astore_1
8: new           #4                  // class TestMain$SubCaller
11: dup
12: invokespecial #5                  // Method TestMain$SubCaller."<init>":()V
15: astore_2
16: aload_2
17: aload_1
18: invokevirtual #6                  // Method TestMain$Caller.call:(Ljava/lang/String;)V
21: return
}
?????????????????
????18: invokevirtual #6 // Method TestMain$Caller.call:(Ljava/lang/String;)V
??????????TestMain$Caller.call????TestMain$SubCaller.call???????????????????????????????????????????????????????????????