I need to manipulate control flow graphs for Java code in a project. What might be a good java library to generate control flow graphs in Java. So far I have found a couple eclipse plugins (heavily dependent on eclipse APIs) and standalone tools (cannot embed in my code).
问题:
回答1:
A tool to do this stuff is Soot, and this questions is a duplicate of Tool for generating control flow in Java
回答2:
jSonde will create sequence diagrams from your actual running code (which is arguably more useful than from source, since source analysis will not show implementation-specific functionality).
javacalltracer does something similar.
Most tools are integrated into Eclipse/similar so they have access to the AST, which makes such things pretty trivial.
It's actually not ridiculously complex to pull the information from byte code yourself (and it's an interesting exercise). Or instrument using AspectJ and create the runtime information yourself.
Edit Original answer, still valid.
JGraph is open-source, and pretty cool.
JDiagram is a Swing component, commercial product.
回答3:
Some examples:
- yFiles for Java (commercial)
- jGraph
- JUNG
- Grappa
If not what you are looking for, then need more info in your question. Most of these options (and many more) are already covered in other similar questions on StackOverflow, even if they are not control flow graph specific. Examples:
- Java library for graphs
- Good Java graph algorithm library?
回答4:
I'll throw another tool into the mix.
Atlas is an Eclipse plugin that enables program analysis. It has a querable graph database that includes the control flow graph (as well as data flow and other relationships).