|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis<FrameType>
edu.umd.cs.findbugs.ba.FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
edu.umd.cs.findbugs.ba.TypeAnalysis
public class TypeAnalysis
A forward dataflow analysis to determine the types of all values in the Java stack frame at all points in a Java method. The values include local variables and values on the Java operand stack.
As a side effect, the analysis computes the exception set throwable on each exception edge in the CFG. This information can be used to prune infeasible exception edges, and mark exception edges which propagate only implicit exceptions.
Dataflow
,
DataflowAnalysis
,
TypeFrame
Nested Class Summary | |
---|---|
private class |
TypeAnalysis.CachedExceptionSet
Repository of information about thrown exceptions computed for a basic block and its outgoing exception edges. |
Field Summary | |
---|---|
private static boolean |
ACCURATE_EXCEPTIONS
Compute what kinds of exceptions can propagate on each exception edge. |
private CFG |
cfg
|
private static boolean |
DEBUG
|
private ExceptionSetFactory |
exceptionSetFactory
|
private RepositoryLookupFailureCallback |
lookupFailureCallback
|
private org.apache.bcel.generic.MethodGen |
methodGen
|
private java.util.Map<BasicBlock,TypeAnalysis.CachedExceptionSet> |
thrownExceptionSetMap
|
private TypeMerger |
typeMerger
|
private TypeFrameModelingVisitor |
visitor
|
Fields inherited from interface edu.umd.cs.findbugs.ba.EdgeTypes |
---|
BACKEDGE_SOURCE_EDGE, BACKEDGE_TARGET_EDGE, CHECKED_EXCEPTIONS_FLAG, EXIT_EDGE, EXPLICIT_EXCEPTIONS_FLAG, FALL_THROUGH_EDGE, GOTO_EDGE, HANDLED_EXCEPTION_EDGE, IFCMP_EDGE, JSR_EDGE, RET_EDGE, RETURN_EDGE, START_EDGE, SWITCH_DEFAULT_EDGE, SWITCH_EDGE, UNHANDLED_EXCEPTION_EDGE, UNKNOWN_EDGE |
Constructor Summary | |
---|---|
TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen,
CFG cfg,
DepthFirstSearch dfs,
RepositoryLookupFailureCallback lookupFailureCallback,
ExceptionSetFactory exceptionSetFactory)
Constructor which uses StandardTypeMerger. |
|
TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen,
CFG cfg,
DepthFirstSearch dfs,
TypeMerger typeMerger,
RepositoryLookupFailureCallback lookupFailureCallback,
ExceptionSetFactory exceptionSetFactory)
Constructor. |
|
TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen,
CFG cfg,
DepthFirstSearch dfs,
TypeMerger typeMerger,
TypeFrameModelingVisitor visitor,
RepositoryLookupFailureCallback lookupFailureCallback,
ExceptionSetFactory exceptionSetFactory)
Constructor. |
Method Summary | |
---|---|
private TypeAnalysis.CachedExceptionSet |
computeBlockExceptionSet(BasicBlock basicBlock,
TypeFrame result)
Compute the set of exceptions that can be thrown from the given basic block. |
private ExceptionSet |
computeEdgeExceptionSet(Edge edge,
ExceptionSet thrownExceptionSet)
Based on the set of exceptions that can be thrown from the source basic block, compute the set of exceptions that can propagate along given exception edge. |
private ExceptionSet |
computeThrownExceptionTypes(BasicBlock basicBlock)
Compute the set of exception types that can be thrown by given basic block. |
void |
copy(TypeFrame source,
TypeFrame dest)
Copy dataflow facts. |
TypeFrame |
createFact()
Create empty (uninitialized) dataflow facts for one program point. |
void |
endTransfer(BasicBlock basicBlock,
org.apache.bcel.generic.InstructionHandle end,
java.lang.Object result)
Subclasses may override this. |
private TypeAnalysis.CachedExceptionSet |
getCachedExceptionSet(BasicBlock basicBlock)
Get the cached set of exceptions that can be thrown from given basic block. |
ExceptionSet |
getEdgeExceptionSet(Edge edge)
Get the set of exceptions that can be thrown on given edge. |
void |
initEntryFact(TypeFrame result)
Initialize the "entry" fact for the graph. |
void |
initResultFact(TypeFrame result)
Initialize result fact for block. |
boolean |
isFactValid(TypeFrame fact)
Determine whether the given fact is valid (neither top nor bottom). |
static void |
main(java.lang.String[] argv)
|
void |
makeFactTop(TypeFrame fact)
Make given fact the top value. |
void |
meetInto(TypeFrame fact,
Edge edge,
TypeFrame result)
Meet a dataflow fact associated with an incoming edge into another fact. |
protected org.apache.bcel.generic.Type |
mergeValues(TypeFrame frame,
int slot,
org.apache.bcel.generic.Type a,
org.apache.bcel.generic.Type b)
Merge two values in a particular slot of a Frame. |
boolean |
same(TypeFrame fact1,
TypeFrame fact2)
Are given dataflow facts the same? |
void |
transferInstruction(org.apache.bcel.generic.InstructionHandle handle,
BasicBlock basicBlock,
TypeFrame fact)
Transfer function for a single instruction. |
Methods inherited from class edu.umd.cs.findbugs.ba.FrameDataflowAnalysis |
---|
mergeInto, modifyFrame |
Methods inherited from class edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis |
---|
getBlockOrder, getDepthFirstSearch, isForwards |
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis |
---|
factToString, getFactAfterLocation, getFactAtLocation, getResultFact, getStartFact, resultFactIterator, startTransfer, transfer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
private static final boolean ACCURATE_EXCEPTIONS
private org.apache.bcel.generic.MethodGen methodGen
private CFG cfg
private TypeMerger typeMerger
private TypeFrameModelingVisitor visitor
private java.util.Map<BasicBlock,TypeAnalysis.CachedExceptionSet> thrownExceptionSetMap
private RepositoryLookupFailureCallback lookupFailureCallback
private ExceptionSetFactory exceptionSetFactory
Constructor Detail |
---|
public TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
methodGen
- the MethodGen whose CFG we'll be analyzingcfg
- the control flow graphdfs
- DepthFirstSearch of the methodtypeMerger
- object to merge typesvisitor
- a TypeFrameModelingVisitor to use to model the effect
of instructionslookupFailureCallback
- lookup failure callbackexceptionSetFactory
- factory for creating ExceptionSet objectspublic TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
methodGen
- the MethodGen whose CFG we'll be analyzingcfg
- the control flow graphdfs
- DepthFirstSearch of the methodtypeMerger
- object to merge typeslookupFailureCallback
- lookup failure callbackexceptionSetFactory
- factory for creating ExceptionSet objectspublic TypeAnalysis(org.apache.bcel.generic.MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
methodGen
- the MethodGen whose CFG we'll be analyzingcfg
- the control flow graphdfs
- DepthFirstSearch of the methodlookupFailureCallback
- callback for Repository lookup failuresexceptionSetFactory
- factory for creating ExceptionSet objectsMethod Detail |
---|
public ExceptionSet getEdgeExceptionSet(Edge edge)
edge
- the Edge
public TypeFrame createFact()
DataflowAnalysis
createFact
in interface DataflowAnalysis<TypeFrame>
public void initEntryFact(TypeFrame result)
DataflowAnalysis
initEntryFact
in interface DataflowAnalysis<TypeFrame>
public void copy(TypeFrame source, TypeFrame dest)
DataflowAnalysis
copy
in interface DataflowAnalysis<TypeFrame>
copy
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
public void initResultFact(TypeFrame result)
DataflowAnalysis
initResultFact
in interface DataflowAnalysis<TypeFrame>
initResultFact
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
public void makeFactTop(TypeFrame fact)
DataflowAnalysis
makeFactTop
in interface DataflowAnalysis<TypeFrame>
makeFactTop
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
public boolean isFactValid(TypeFrame fact)
AbstractDataflowAnalysis
isFactValid
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
public boolean same(TypeFrame fact1, TypeFrame fact2)
DataflowAnalysis
same
in interface DataflowAnalysis<TypeFrame>
same
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
public void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, TypeFrame fact) throws DataflowAnalysisException
AbstractDataflowAnalysis
transferInstruction
in class AbstractDataflowAnalysis<TypeFrame>
handle
- the instructionbasicBlock
- the BasicBlock containing the instruction; needed to disambiguate
instructions in inlined JSR subroutinesfact
- which should be modified based on the instruction
DataflowAnalysisException
public void endTransfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, java.lang.Object result) throws DataflowAnalysisException
AbstractDataflowAnalysis
endTransfer
in class AbstractDataflowAnalysis<TypeFrame>
basicBlock
- the basic blockend
- last instruction analyzed (null if entire block was analyzed)result
- the result fact for the block
DataflowAnalysisException
public void meetInto(TypeFrame fact, Edge edge, TypeFrame result) throws DataflowAnalysisException
DataflowAnalysis
meetInto
in interface DataflowAnalysis<TypeFrame>
fact
- the predecessor fact (incoming edge)edge
- the edge from the predecessorresult
- the result fact
DataflowAnalysisException
protected org.apache.bcel.generic.Type mergeValues(TypeFrame frame, int slot, org.apache.bcel.generic.Type a, org.apache.bcel.generic.Type b) throws DataflowAnalysisException
FrameDataflowAnalysis
mergeValues
in class FrameDataflowAnalysis<org.apache.bcel.generic.Type,TypeFrame>
frame
- the Frameslot
- the slot of the Framea
- a valueb
- another value
DataflowAnalysisException
private TypeAnalysis.CachedExceptionSet getCachedExceptionSet(BasicBlock basicBlock)
basicBlock
- the block to get the cached exception set for
private TypeAnalysis.CachedExceptionSet computeBlockExceptionSet(BasicBlock basicBlock, TypeFrame result) throws DataflowAnalysisException
basicBlock
- the basic blockresult
- the result fact for the block; this is used
to determine whether or not the cached exception
set is up to date
DataflowAnalysisException
private ExceptionSet computeEdgeExceptionSet(Edge edge, ExceptionSet thrownExceptionSet)
edge
- the exception edgethrownExceptionSet
- current set of exceptions that
can be thrown, taking earlier (higher priority)
exception edges into account
private ExceptionSet computeThrownExceptionTypes(BasicBlock basicBlock) throws java.lang.ClassNotFoundException, DataflowAnalysisException
basicBlock
- the basic block
java.lang.ClassNotFoundException
DataflowAnalysisException
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |