How to create a simple static call graph in Java?

ict1991 picture ict1991 · Feb 15, 2012 · Viewed 7.2k times · Source

I would like to generate a simple call graph in order to be able to analyze the flow of execution in methods in java.

So for example, if in the code I'm able to go from method X to method Y in a number of method calls, then I would like to generate the call graph which shows the flow from method X to method Y.

I tried using SOOT however I did not manage to get this required call graph. Does anyone know of an API which I can use to generate such call graphs? I'm using Eclipse, however I cannot use plugins, as this tool is needed to be used across a number of projects

Thanks a lot for your help

Answer

jbranchaud picture jbranchaud · Feb 18, 2012

I have been looking into what static analysis libraries are available for Java recently. Here are some of them that I have come across:

  • Chord: seems to be a robust framework that is still being maintained/updated. Here is a link to some of the documentation on their predefined analysis (includes Call Graph stuff).
  • DepFinder: this tool is used for generating a dependency graph from a project, I imagine you could extract static call graph information from it.