Class ControlFlow
- java.lang.Object
-
- javassist.bytecode.analysis.ControlFlow
-
public class ControlFlow extends java.lang.Object
Represents the control flow graph of a given method.To obtain the control flow graph, do the following:
CtMethod m = ... ControlFlow cf = new ControlFlow(m); Block[] blocks = cf.basicBlocks();
blocks
is an array of basic blocks in that method body.- Since:
- 3.16
- See Also:
CtMethod
,ControlFlow.Block
,Frame
,Analyzer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ControlFlow.Access
static class
ControlFlow.Block
Basic block.static class
ControlFlow.Catcher
Represents a catch clause.static class
ControlFlow.Node
A node of (post) dominator trees.
-
Field Summary
Fields Modifier and Type Field Description private ControlFlow.Block[]
basicBlocks
private CtClass
clazz
private Frame[]
frames
private MethodInfo
methodInfo
-
Constructor Summary
Constructors Constructor Description ControlFlow(CtClass ctclazz, MethodInfo minfo)
Constructs a control-flow analyzer.ControlFlow(CtMethod method)
Constructs a control-flow analyzer for the given method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ControlFlow.Block[]
basicBlocks()
Returns all the basic blocks in the method body.ControlFlow.Node[]
dominatorTree()
Constructs a dominator tree.Frame
frameAt(int pos)
Returns the types of the local variables and stack frame entries available at the given position.ControlFlow.Node[]
postDominatorTree()
Constructs a post dominator tree.
-
-
-
Field Detail
-
clazz
private CtClass clazz
-
methodInfo
private MethodInfo methodInfo
-
basicBlocks
private ControlFlow.Block[] basicBlocks
-
frames
private Frame[] frames
-
-
Constructor Detail
-
ControlFlow
public ControlFlow(CtMethod method) throws BadBytecode
Constructs a control-flow analyzer for the given method.- Throws:
BadBytecode
-
ControlFlow
public ControlFlow(CtClass ctclazz, MethodInfo minfo) throws BadBytecode
Constructs a control-flow analyzer.- Throws:
BadBytecode
-
-
Method Detail
-
basicBlocks
public ControlFlow.Block[] basicBlocks()
Returns all the basic blocks in the method body.- Returns:
- an array of basic blocks, the array has length 0 if the method doesn't have code.
-
frameAt
public Frame frameAt(int pos) throws BadBytecode
Returns the types of the local variables and stack frame entries available at the given position. If the byte at the position is not the first byte of an instruction, then this method returns null.- Parameters:
pos
- the position.- Throws:
BadBytecode
-
dominatorTree
public ControlFlow.Node[] dominatorTree()
Constructs a dominator tree. This method returns an array of the tree nodes. The first element of the array is the root of the tree.The order of the elements is the same as that of the elements in the
Block
array returned by thebasicBlocks
method. If aBlock
object is at the i-th position in theBlock
array, then theNode
object referring to thatBlock
object is at the i-th position in the array returned by this method. For every array elementnode
, its index in the array is equivalent tonode.block().index()
.- Returns:
- an array of the tree nodes, or null if the method doesn't have code.
- See Also:
ControlFlow.Node.block()
,ControlFlow.Block.index()
-
postDominatorTree
public ControlFlow.Node[] postDominatorTree()
Constructs a post dominator tree. This method returns an array of the tree nodes. Note that the tree has multiple roots. The parent of the root nodes is null.The order of the elements is the same as that of the elements in the
Block
array returned by thebasicBlocks
method. If aBlock
object is at the i-th position in theBlock
array, then theNode
object referring to thatBlock
object is at the i-th position in the array returned by this method. For every array elementnode
, its index in the array is equivalent tonode.block().index()
.- Returns:
- an array of the tree nodes, or null if the method doesn't have code.
- See Also:
ControlFlow.Node.block()
,ControlFlow.Block.index()
-
-