Last active
August 29, 2015 14:26
-
-
Save jsyeo/122565cb929558d846df to your computer and use it in GitHub Desktop.
Class Hierarchy Analysis Example
This file contains hidden or 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
| public class Main { | |
| public static void main(String[] args) { | |
| H h = new H(); | |
| h.m(); | |
| // receiver has a declared class H, which is a subclass of C and H does not override method m | |
| // therefore we are sure we are calling C.m here. | |
| A a = new C(); | |
| a.m(); | |
| // We can be sure we are calling C.m here as A is never instantiated. | |
| } | |
| } | |
| class H extends F {} | |
| class G extends F {} | |
| class F extends C { | |
| @Override | |
| void p() { | |
| } | |
| } | |
| class E extends C { | |
| @Override | |
| void m() { | |
| } | |
| } | |
| class D extends B { | |
| } | |
| class C extends A { | |
| @Override | |
| void m() { | |
| } | |
| } | |
| class B extends A { | |
| @Override | |
| void m() { | |
| } | |
| } | |
| class A { | |
| void m() { | |
| } | |
| void p() { | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Example from http://web.cs.ucla.edu/~palsberg/tba/papers/dean-grove-chambers-ecoop95.pdf