Reputation: 23
Is there any API or reference library available to parse a java code or java method into control flow graph (CFG).
I tried to convert AST into CFG but couldn't do it using AST Parser but didnt find any way to do so.
I am working on Eclipse IDE JAVA (J2SE).
Kindly help.
Upvotes: 2
Views: 1970
Reputation: 1
yes, the is " code visualizer" you can use it with Java Eclipse to automatically generate CFG for code: https://marketplace.eclipse.org/content/control-flow-graph-factory
Upvotes: 0
Reputation: 47699
doSomethingA;
while(B) {
doSomethingC;
doSomethingD;
if (E) {
doSomethingF;
}
else {
doSomethingG;
}
doSomethingH;
doSomethingI;
}
doSomethingJ;
Basic blocks:
Arcs:
As a data structure, a basic block has a list of statements and a list of exit arcs. One may also keep a list of entry arcs, for certain types of analysis, and one may choose to have a data structure to represent each arc, or simply have blocks point to other blocks.
Upvotes: 1