Static Call Graph Generator for Java Projects
You must have Java and Maven installed
$ git clone [email protected]:wcygan/java-callgraph.git
$ cd java-callgraph
$ mvn install
This will produce a target
directory with the following jar:
javacg-0.1-SNAPSHOT-jar-with-dependencies.jar
: This is an executable jar which includes the static call graph generator and all dependencies needed to run this program
After running mvn install
, you can test this program by running the following code in the root directory:
$ java -jar ./target/javacg-0.1-SNAPSHOT-jar-with-dependencies.jar -j ./output/java-callgraph-driver-1.0-SNAPSHOT.jar -o example -e "edu.uic.cs398.Main.main([Ljava/lang/String;)V" -c ./output/jacoco.xml
This program will generate a graph and save it to a file <output-name>.dot
which you can use Graphviz to visualize.
A directed edge in the graph is denoted with two fully qualified method signatures:
"class1.method1(descriptor)" -> "class2.method2(descriptor)"
For example:
"edu.uic.cs398.Main.main([Ljava/lang/String;)V" -> "edu.uic.cs398.Book.Book.magic()V"
There are command line options that can be used:
Option | Usage | Example |
---|---|---|
-j |
The path to a jar file to inspect | -j ./output/java-callgraph-driver-1.0-SNAPSHOT.jar |
-c |
The path to the coverage file to use | -c ./output/jacoco.xml |
-e |
The name of the fuzzer's entrypoint | -e "edu.uic.cs398.Main.main([Ljava/lang/String;)V" |
-d |
The depth to run breadth first search | -d 10 |
-a |
Report the ancestry of the entrypoint | -a |
-o |
The name of the output file | -o example |
- The static call graph generator does not account for methods invoked via reflection.
Georgios Gousios [email protected]
Will Cygan [email protected]