edu.umd.cs.findbugs.ba.type

Class TypeAnalysis

public class TypeAnalysis extends FrameDataflowAnalysis<Type,TypeFrame> implements EdgeTypes

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.

Author: David Hovemeyer

See Also: Dataflow DataflowAnalysis TypeFrame

Field Summary
protected CFGcfg
static booleanDEBUG
static booleanFORCE_ACCURATE_EXCEPTIONS
Force computation of accurate exceptions.
protected MethodGenmethodGen
Constructor Summary
TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor.
TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor.
TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor which uses StandardTypeMerger.
Method Summary
TypeFramecreateFact()
ExceptionSetgetEdgeExceptionSet(Edge edge)
Get the set of exceptions that can be thrown on given edge.
voidinitEntryFact(TypeFrame result)
static voidmain(String[] argv)
voidmeetInto(TypeFrame fact, Edge edge, TypeFrame result)
voidsetFieldStoreTypeDatabase(FieldStoreTypeDatabase database)
Set the FieldStoreTypeDatabase.
voidsetValueNumberDataflow(ValueNumberDataflow valueNumberDataflow)
Set the ValueNumberDataflow for the method being analyzed.

Field Detail

cfg

protected CFG cfg

DEBUG

public static final boolean DEBUG

FORCE_ACCURATE_EXCEPTIONS

public static final boolean FORCE_ACCURATE_EXCEPTIONS
Force computation of accurate exceptions.

methodGen

protected MethodGen methodGen

Constructor Detail

TypeAnalysis

public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor.

Parameters: method TODO methodGen the MethodGen whose CFG we'll be analyzing cfg the control flow graph dfs DepthFirstSearch of the method typeMerger object to merge types visitor a TypeFrameModelingVisitor to use to model the effect of instructions lookupFailureCallback lookup failure callback exceptionSetFactory factory for creating ExceptionSet objects

TypeAnalysis

public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor.

Parameters: method TODO methodGen the MethodGen whose CFG we'll be analyzing cfg the control flow graph dfs DepthFirstSearch of the method typeMerger object to merge types lookupFailureCallback lookup failure callback exceptionSetFactory factory for creating ExceptionSet objects

TypeAnalysis

public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory)
Constructor which uses StandardTypeMerger.

Parameters: method TODO methodGen the MethodGen whose CFG we'll be analyzing cfg the control flow graph dfs DepthFirstSearch of the method lookupFailureCallback callback for Repository lookup failures exceptionSetFactory factory for creating ExceptionSet objects

Method Detail

createFact

public TypeFrame createFact()

getEdgeExceptionSet

public ExceptionSet getEdgeExceptionSet(Edge edge)
Get the set of exceptions that can be thrown on given edge. This should only be called after the analysis completes.

Parameters: edge the Edge

Returns: the ExceptionSet

initEntryFact

public void initEntryFact(TypeFrame result)

main

public static void main(String[] argv)

meetInto

public void meetInto(TypeFrame fact, Edge edge, TypeFrame result)

setFieldStoreTypeDatabase

public void setFieldStoreTypeDatabase(FieldStoreTypeDatabase database)
Set the FieldStoreTypeDatabase. This can be used to get more accurate types for values loaded from fields.

Parameters: database the FieldStoreTypeDatabase

setValueNumberDataflow

public void setValueNumberDataflow(ValueNumberDataflow valueNumberDataflow)
Set the ValueNumberDataflow for the method being analyzed. This is optional; if set, it will be used to make instanceof instructions more precise.

Parameters: valueNumberDataflow the ValueNumberDataflow

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.