Top Description Inners Fields Constructors Methods
org.apache.bcel.verifier.structurals

public Class ControlFlowGraph

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .HashMap, .List, .Map, org.apache.bcel.generic.ATHROW, .BranchInstruction, .GotoInstruction, .Instruction, .InstructionHandle, .JsrInstruction, .MethodGen, .RET, .ReturnInstruction, .Select, org.apache.bcel.verifier.exc.AssertionViolatedException, .StructuralCodeConstraintException

This class represents a control flow graph of a method.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ControlFlowGraph.InstructionContextImpl

Objects of this class represent a node in a ControlFlowGraph.

Field Summary

Modifier and TypeField and Description
private final ExceptionHandlers
exceptionhandlers

The ExceptionHandlers object for the method whose control flow is represented by this ControlFlowGraph.

private final Map<InstructionHandle, InstructionContext>
instructionContexts

All InstructionContext instances of this ControlFlowGraph.

private final Subroutines
subroutines

The Subroutines object for the method whose control flow is represented by this ControlFlowGraph.

Constructor Summary

AccessConstructor and Description
public
ControlFlowGraph(final MethodGen
the method generator instance
methodGen
)

A Control Flow Graph; with additional JustIce checks

public
ControlFlowGraph(final MethodGen
the method generator instance
methodGen
,
final boolean
if true, additional JustIce checks are performed
enableJustIceCheck
)

A Control Flow Graph.

Method Summary

Modifier and TypeMethod and Description
public InstructionContext
contextOf(final InstructionHandle inst)

Returns the InstructionContext of a given instruction.

public InstructionContext[]
contextsOf(final InstructionHandle[] insts)

Returns the InstructionContext[] of a given InstructionHandle[], in a naturally ordered manner.

public InstructionContext[]
getInstructionContexts()

Returns an InstructionContext[] with all the InstructionContext instances for the method whose control flow is represented by this ControlFlowGraph (NOT ORDERED!).

public boolean
isDead(final InstructionHandle i)

Returns true, if and only if the said instruction is not reachable; that means, if it is not part of this ControlFlowGraph.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exceptionhandlersback to summary
private final ExceptionHandlers exceptionhandlers

The ExceptionHandlers object for the method whose control flow is represented by this ControlFlowGraph.

instructionContextsback to summary
private final Map<InstructionHandle, InstructionContext> instructionContexts

All InstructionContext instances of this ControlFlowGraph.

subroutinesback to summary
private final Subroutines subroutines

The Subroutines object for the method whose control flow is represented by this ControlFlowGraph.

Constructor Detail

ControlFlowGraphback to summary
public ControlFlowGraph(final MethodGen methodGen)

A Control Flow Graph; with additional JustIce checks

Parameters
methodGen:MethodGen

the method generator instance

ControlFlowGraphback to summary
public ControlFlowGraph(final MethodGen methodGen, final boolean enableJustIceCheck)

A Control Flow Graph.

Parameters
methodGen:MethodGen

the method generator instance

enableJustIceCheck:boolean

if true, additional JustIce checks are performed

Since
6.0

Method Detail

contextOfback to summary
public InstructionContext contextOf(final InstructionHandle inst)

Returns the InstructionContext of a given instruction.

contextsOfback to summary
public InstructionContext[] contextsOf(final InstructionHandle[] insts)

Returns the InstructionContext[] of a given InstructionHandle[], in a naturally ordered manner.

getInstructionContextsback to summary
public InstructionContext[] getInstructionContexts()

Returns an InstructionContext[] with all the InstructionContext instances for the method whose control flow is represented by this ControlFlowGraph (NOT ORDERED!).

isDeadback to summary
public boolean isDead(final InstructionHandle i)

Returns true, if and only if the said instruction is not reachable; that means, if it is not part of this ControlFlowGraph.

org.apache.bcel.verifier.structurals back to summary

private final Class ControlFlowGraph.InstructionContextImpl

extends Object
implements InstructionContext
Class Inheritance
  • java.lang.Object
  • org.apache.bcel.verifier.structurals.ControlFlowGraph.InstructionContextImpl
All Implemented Interfaces
org.apache.bcel.verifier.structurals.InstructionContext

Objects of this class represent a node in a ControlFlowGraph. These nodes are instructions, not basic blocks.

Field Summary

Modifier and TypeField and Description
private List<InstructionContext>
executionPredecessors

The 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in that order.

private final Map<InstructionContext, Frame>
inFrames

The 'incoming' execution Frames.

private final InstructionHandle
instruction

The InstructionHandle this InstructionContext is wrapped around.

private final Map<InstructionContext, Frame>
outFrames

The 'outgoing' execution Frames.

private int
TAG

The TAG field is here for external temporary flagging, such as graph coloring.

Constructor Summary

AccessConstructor and Description
public
InstructionContextImpl(final InstructionHandle inst)

Creates an InstructionHandleImpl object from an InstructionHandle.

Method Summary

Modifier and TypeMethod and Description
private InstructionHandle[]
_getSuccessors()

A utility method that calculates the successors of a given InstructionHandle That means, a RET does have successors as defined here.

public boolean

Returns:

true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
execute
(final Frame inFrame, final ArrayList<InstructionContext> execPreds, final InstConstraintVisitor icv, final ExecutionVisitor ev)

Implements org.apache.bcel.verifier.structurals.InstructionContext.execute.

"Merges in" (vmspec2, page 146) the "incoming" frame situation; executes the instructions symbolically and therefore calculates the "outgoing" frame situation.
private void
extendMessageWithFlow(final StructuralCodeConstraintException e)

Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message.

public ExceptionHandler[]
getExceptionHandlers()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getExceptionHandlers.

Returns the exception handlers of this instruction.
private String
getExecutionChain()

Returns the control flow execution chain.

public Frame
public InstructionHandle
getInstruction()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getInstruction.

Returns the InstructionHandle this InstructionContext is wrapped around.
public Frame
getOutFrame(final ArrayList<InstructionContext> execChain)

Implements org.apache.bcel.verifier.structurals.InstructionContext.getOutFrame.

Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.
public InstructionContext[]
getSuccessors()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getSuccessors.

Returns the usual control flow successors.
public int
getTag()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getTag.

The getTag and setTag methods may be used for temporary flagging, such as graph coloring.
private ControlFlowGraph.InstructionContextImpl
lastExecutionJSR()

Returns the InstructionContextImpl with an JSR/JSR_W that was last in the ExecutionChain, without a corresponding RET, i.e. we were called by this one.

private boolean
mergeInFrames(final Frame inFrame)

Does the actual merging (vmspec2, page 146).

public void
setTag(final int tag)

Implements org.apache.bcel.verifier.structurals.InstructionContext.setTag.

The getTag and setTag methods may be used for temporary flagging, such as graph coloring.
public String
toString()

Overrides java.lang.Object.toString.

Returns a simple String representation of this InstructionContext.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

executionPredecessorsback to summary
private List<InstructionContext> executionPredecessors

The 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in that order.

inFramesback to summary
private final Map<InstructionContext, Frame> inFrames

The 'incoming' execution Frames.

instructionback to summary
private final InstructionHandle instruction

The InstructionHandle this InstructionContext is wrapped around.

outFramesback to summary
private final Map<InstructionContext, Frame> outFrames

The 'outgoing' execution Frames.

TAGback to summary
private int TAG

The TAG field is here for external temporary flagging, such as graph coloring.

See Also
getTag(), setTag(int)

Constructor Detail

InstructionContextImplback to summary
public InstructionContextImpl(final InstructionHandle inst)

Creates an InstructionHandleImpl object from an InstructionHandle. Creation of one per InstructionHandle suffices. Don't create more.

Method Detail

_getSuccessorsback to summary
private InstructionHandle[] _getSuccessors()

A utility method that calculates the successors of a given InstructionHandle That means, a RET does have successors as defined here. A JsrInstruction has its target as its successor (opposed to its physical successor) as defined here.

executeback to summary
public boolean execute(final Frame inFrame, final ArrayList<InstructionContext> execPreds, final InstConstraintVisitor icv, final ExecutionVisitor ev)

Implements org.apache.bcel.verifier.structurals.InstructionContext.execute.

"Merges in" (vmspec2, page 146) the "incoming" frame situation; executes the instructions symbolically and therefore calculates the "outgoing" frame situation. Returns: True iff the "incoming" frame situation changed after merging with "inFrame". The execPreds ArrayList must contain the InstructionContext objects executed so far in the correct order. This is just one execution path [out of many]. This is needed to correctly "merge" in the special case of a RET's successor. The InstConstraintVisitor and ExecutionVisitor instances must be set up correctly.

Returns:boolean

true - if and only if the "outgoing" frame situation changed from the one before execute()ing.

Annotations
@Override
extendMessageWithFlowback to summary
private void extendMessageWithFlow(final StructuralCodeConstraintException e)

Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message. This extended message will then reflect the execution flow needed to get to the constraint violation that triggered the throwing of the "e" object.

getExceptionHandlersback to summary
public ExceptionHandler[] getExceptionHandlers()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getExceptionHandlers.

Returns the exception handlers of this instruction.

Annotations
@Override
getExecutionChainback to summary
private String getExecutionChain()

Returns the control flow execution chain. This is built while execute(Frame, ArrayList)-ing the code represented by the surrounding ControlFlowGraph.

getInFrameback to summary
public Frame getInFrame()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getInFrame.

Annotations
@Override
getInstructionback to summary
public InstructionHandle getInstruction()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getInstruction.

Doc from org.apache.bcel.verifier.structurals.InstructionContext.getInstruction.

Returns the InstructionHandle this InstructionContext is wrapped around.

Returns:InstructionHandle

The InstructionHandle this InstructionContext is wrapped around.

Annotations
@Override
getOutFrameback to summary
public Frame getOutFrame(final ArrayList<InstructionContext> execChain)

Implements org.apache.bcel.verifier.structurals.InstructionContext.getOutFrame.

Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.

Annotations
@Override
getSuccessorsback to summary
public InstructionContext[] getSuccessors()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getSuccessors.

Doc from org.apache.bcel.verifier.structurals.InstructionContext.getSuccessors.

Returns the usual control flow successors.

Annotations
@Override
getTagback to summary
public int getTag()

Implements org.apache.bcel.verifier.structurals.InstructionContext.getTag.

Doc from org.apache.bcel.verifier.structurals.InstructionContext.getTag.

The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the InstructionContext object depends on the value of the tag. JustIce does not use it.

Annotations
@Override
lastExecutionJSRback to summary
private ControlFlowGraph.InstructionContextImpl lastExecutionJSR()

Returns the InstructionContextImpl with an JSR/JSR_W that was last in the ExecutionChain, without a corresponding RET, i.e. we were called by this one. Returns null if we were called from the top level.

mergeInFramesback to summary
private boolean mergeInFrames(final Frame inFrame)

Does the actual merging (vmspec2, page 146). Returns true IFF this.inFrame was changed in course of merging with inFrame.

setTagback to summary
public void setTag(final int tag)

Implements org.apache.bcel.verifier.structurals.InstructionContext.setTag.

Doc from org.apache.bcel.verifier.structurals.InstructionContext.setTag.

The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the InstructionContext object depends on the value of the tag. JustIce does not use it.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a simple String representation of this InstructionContext.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override