Class Hierarchy Analysis: a quick way to generate call graph
The key to call graph construction
For an OOP programming language, the key challenge in call graph construction is handling the virtual call, as it may involve multiple target methods, as shown in the following table1.
| Static Call | Special Call | Virtual Call | |
|---|---|---|---|
| Instruction | invokestatic |
invokespecial |
invokeinterface, invokevirtual |
| Receiver Objects | ❌ | ✅ | ✅ |
| Target Methods | Static Method | Constructor, Private Instance Method, Superclass Instance Method | Other Instance Method |
| Count of Possible Target Methods | 1 | 1 | $\ge 1$ (polymorphism) |
| Determinancy | Compile-time | Compile-time | Run-time |
The method call and method signature
Let’s take Java as an example; a method call may have this form.