edu.umd.cs.findbugs.ba

Class ClassContext

public class ClassContext extends Object

A ClassContext caches all of the auxiliary objects used to analyze the methods of a class. That way, these objects don't need to be created over and over again.

Author: David Hovemeyer

Field Summary
static booleanDEBUG
Constructor Summary
ClassContext(JavaClass jclass, AnalysisContext analysisContext)
Constructor.
Method Summary
voiddumpDataflowInformation(Method method)
static voiddumpDataflowInformation(Method method, CFG cfg, ValueNumberDataflow vnd, IsNullValueDataflow inv, UnconditionalValueDerefDataflow dataflow, TypeDataflow typeDataflow)
static voiddumpTypeDataflow(Method method, CFG cfg, TypeDataflow typeDataflow)
AnalysisContextgetAnalysisContext()
Get the AnalysisContext.
AssertionMethodsgetAssertionMethods()
Get AssertionMethods for class.
AssignedFieldMapgetAssignedFieldMap()
Get the assigned field map for the class.
Dataflow<BlockType,BlockTypeAnalysis>getBlockTypeDataflow(Method method)
Get BlockType dataflow for given method.
BitSetgetBytecodeSet(JavaClass clazz, Method method)
Get a BitSet representing the bytecodes that are used in the given method.
CallListDataflowgetCallListDataflow(Method method)
Get CallListDataflow for method.
CFGgetCFG(Method method)
Get a CFG for given method.
CompactLocationNumberinggetCompactLocationNumbering(Method method)
Get a CompactLocationNumbering for a method.
ConstantDataflowgetConstantDataflow(Method method)
Get ConstantDataflow for method.
DefinitelyNullSetDataflowgetDefinitelyNullSetDataflow(Method method)
Get DefinitelyNullSetDataflow for a method.
DepthFirstSearchgetDepthFirstSearch(Method method)
Get a DepthFirstSearch for given method.
ExceptionSetFactorygetExceptionSetFactory(Method method)
Get ExceptionSetFactory for given method.
IsNullValueDataflowgetIsNullValueDataflow(Method method)
Get an IsNullValueDataflow for given method.
JavaClassgetJavaClass()
Get the JavaClass.
LiveLocalStoreDataflowgetLiveLocalStoreDataflow(Method method)
Get LiveLocalStoreAnalysis dataflow for given method.
LoadDataflowgetLoadDataflow(Method method)
Get load dataflow.
LoadedFieldSetgetLoadedFieldSet(Method method)
Get the set of fields loaded by given method.
LockCheckergetLockChecker(Method method)
Get LockChecker for method.
LockDataflowgetLockDataflow(Method method)
Get dataflow for LockAnalysis for given method.
RepositoryLookupFailureCallbackgetLookupFailureCallback()
Get the RepositoryLookupFailureCallback.
Set<Integer>getLoopExitBranches(Method method, MethodGen methodGen)
MethodgetMethod(MethodGen methodGen)
Look up the Method represented by given MethodGen.
DominatorsAnalysisgetNonExceptionDominatorsAnalysis(Method method)
Get DominatorsAnalysis for given method, where exception edges are ignored.
PostDominatorsAnalysisgetNonExceptionPostDominatorsAnalysis(Method method)
Get PostDominatorsAnalysis for given method, where exception edges are ignored.
PostDominatorsAnalysisgetNonImplicitExceptionDominatorsAnalysis(Method method)
Get DominatorsAnalysis for given method, where implicit exception edges are ignored.
short[]getOffsetToOpcodeMap(Method method)
Get array mapping bytecode offsets to opcodes for given method.
String[]getParameterSignatureList(Method method)
Get array of type signatures of parameters for given method.
CFGgetRawCFG(Method method)
Get a "raw" CFG for given method.
ReturnPathDataflowgetReturnPathDataflow(Method method)
Get ReturnPathDataflow for method.
ReturnPathTypeDataflowgetReturnPathTypeDataflow(Method method)
Get ReturnPathTypeDataflow for a method.
ReverseDepthFirstSearchgetReverseDepthFirstSearch(Method method)
Get a ReverseDepthFirstSearch for given method.
StoreDataflowgetStoreDataflow(Method method)
Get store dataflow.
TypeDataflowgetTypeDataflow(Method method)
Get a TypeDataflow for given method.
UnconditionalValueDerefDataflowgetUnconditionalValueDerefDataflow(Method method)
Get the UnconditionalValueDerefDataflow for a method.
UsagesRequiringNonNullValuesgetUsagesRequiringNonNullValues(Method method)
Get a UsagesRequiringNonNullValues for given method.
ValueNumberDataflowgetValueNumberDataflow(Method method)
Get a ValueNumberDataflow for given method.
static BitSetlinesMentionedMultipleTimes(Method method)

Field Detail

DEBUG

public static final boolean DEBUG

Constructor Detail

ClassContext

public ClassContext(JavaClass jclass, AnalysisContext analysisContext)
Constructor.

Parameters: jclass the JavaClass

Method Detail

dumpDataflowInformation

public void dumpDataflowInformation(Method method)

dumpDataflowInformation

public static void dumpDataflowInformation(Method method, CFG cfg, ValueNumberDataflow vnd, IsNullValueDataflow inv, UnconditionalValueDerefDataflow dataflow, TypeDataflow typeDataflow)

Parameters: method cfg vnd inv dataflow typeDataflow TODO

Throws: DataflowAnalysisException

dumpTypeDataflow

public static void dumpTypeDataflow(Method method, CFG cfg, TypeDataflow typeDataflow)

Parameters: method cfg typeDataflow

Throws: DataflowAnalysisException

getAnalysisContext

public AnalysisContext getAnalysisContext()
Get the AnalysisContext.

getAssertionMethods

public AssertionMethods getAssertionMethods()
Get AssertionMethods for class.

Returns: the AssertionMethods

getAssignedFieldMap

public AssignedFieldMap getAssignedFieldMap()
Get the assigned field map for the class.

Returns: the AssignedFieldMap

Throws: ClassNotFoundException if a class lookup prevents the class's superclasses from being searched for assignable fields

getBlockTypeDataflow

public Dataflow<BlockType,BlockTypeAnalysis> getBlockTypeDataflow(Method method)
Get BlockType dataflow for given method.

Parameters: method the method

Returns: the Dataflow object for BlockTypeAnalysis on the method

getBytecodeSet

public BitSet getBytecodeSet(JavaClass clazz, Method method)
Get a BitSet representing the bytecodes that are used in the given method. This is useful for prescreening a method for the existence of particular instructions. Because this step doesn't require building a MethodGen, it is very fast and memory-efficient. It may allow a Detector to avoid some very expensive analysis, which is a Big Win for the user.

Parameters: method the method

Returns: the BitSet containing the opcodes which appear in the method, or null if the method has no code

getCallListDataflow

public CallListDataflow getCallListDataflow(Method method)
Get CallListDataflow for method.

Parameters: method the method

Returns: the CallListDataflow

Throws: CFGBuilderException DataflowAnalysisException

getCFG

public CFG getCFG(Method method)
Get a CFG for given method. If pruning options are in effect, pruning will be done. Because the CFG pruning can involve interprocedural analysis, it is done on a best-effort basis, so the CFG returned might not actually be pruned.

Parameters: method the method

Returns: the CFG

Throws: CFGBuilderException if a CFG cannot be constructed for the method

getCompactLocationNumbering

public CompactLocationNumbering getCompactLocationNumbering(Method method)
Get a CompactLocationNumbering for a method.

Parameters: method a method

Returns: the CompactLocationNumbering for the method

Throws: CFGBuilderException

getConstantDataflow

public ConstantDataflow getConstantDataflow(Method method)
Get ConstantDataflow for method.

Parameters: method the method

Returns: the ConstantDataflow

Throws: CFGBuilderException DataflowAnalysisException

getDefinitelyNullSetDataflow

public DefinitelyNullSetDataflow getDefinitelyNullSetDataflow(Method method)
Get DefinitelyNullSetDataflow for a method.

Parameters: method a method

Returns: the DefinitelyNullSetDataflow for the method

Throws: DataflowAnalysisException CFGBuilderException

getDepthFirstSearch

public DepthFirstSearch getDepthFirstSearch(Method method)
Get a DepthFirstSearch for given method.

Parameters: method the method

Returns: the DepthFirstSearch

getExceptionSetFactory

public ExceptionSetFactory getExceptionSetFactory(Method method)
Get ExceptionSetFactory for given method.

Parameters: method the method

Returns: the ExceptionSetFactory

getIsNullValueDataflow

public IsNullValueDataflow getIsNullValueDataflow(Method method)
Get an IsNullValueDataflow for given method.

Parameters: method the method

Returns: the IsNullValueDataflow

getJavaClass

public JavaClass getJavaClass()
Get the JavaClass.

getLiveLocalStoreDataflow

public LiveLocalStoreDataflow getLiveLocalStoreDataflow(Method method)
Get LiveLocalStoreAnalysis dataflow for given method.

Parameters: method the method

Returns: the Dataflow object for LiveLocalStoreAnalysis on the method

getLoadDataflow

public LoadDataflow getLoadDataflow(Method method)
Get load dataflow.

Parameters: method the method

Returns: the LoadDataflow

Throws: CFGBuilderException DataflowAnalysisException

getLoadedFieldSet

public LoadedFieldSet getLoadedFieldSet(Method method)
Get the set of fields loaded by given method.

Parameters: method the method

Returns: the set of fields loaded by the method

getLockChecker

public LockChecker getLockChecker(Method method)
Get LockChecker for method. This is like LockDataflow, but may be able to avoid performing the actual dataflow analyses if the method doesn't contain explicit monitorenter/monitorexit instructions.

Parameters: method the method

Returns: the LockChecker

Throws: CFGBuilderException DataflowAnalysisException

getLockDataflow

public LockDataflow getLockDataflow(Method method)
Get dataflow for LockAnalysis for given method.

Parameters: method the method

Returns: the LockDataflow

getLookupFailureCallback

public RepositoryLookupFailureCallback getLookupFailureCallback()
Get the RepositoryLookupFailureCallback.

Returns: the RepositoryLookupFailureCallback

getLoopExitBranches

public Set<Integer> getLoopExitBranches(Method method, MethodGen methodGen)

getMethod

public Method getMethod(MethodGen methodGen)
Look up the Method represented by given MethodGen.

Parameters: methodGen a MethodGen

Returns: the Method represented by the MethodGen

getNonExceptionDominatorsAnalysis

public DominatorsAnalysis getNonExceptionDominatorsAnalysis(Method method)
Get DominatorsAnalysis for given method, where exception edges are ignored.

Parameters: method the method

Returns: the DominatorsAnalysis

getNonExceptionPostDominatorsAnalysis

public PostDominatorsAnalysis getNonExceptionPostDominatorsAnalysis(Method method)
Get PostDominatorsAnalysis for given method, where exception edges are ignored.

Parameters: method the method

Returns: the PostDominatorsAnalysis

getNonImplicitExceptionDominatorsAnalysis

public PostDominatorsAnalysis getNonImplicitExceptionDominatorsAnalysis(Method method)
Get DominatorsAnalysis for given method, where implicit exception edges are ignored.

Parameters: method the method

Returns: the DominatorsAnalysis

getOffsetToOpcodeMap

public short[] getOffsetToOpcodeMap(Method method)
Get array mapping bytecode offsets to opcodes for given method. Array elements containing zero are either not valid instruction offsets, or contain a NOP instruction. (It is convenient not to distinguish these cases.)

Parameters: method the method

Returns: map of bytecode offsets to opcodes, or null if the method has no code

getParameterSignatureList

public String[] getParameterSignatureList(Method method)
Get array of type signatures of parameters for given method.

Parameters: method the method

Returns: an array of type signatures indicating the types of the method's parameters

getRawCFG

public CFG getRawCFG(Method method)
Get a "raw" CFG for given method. No pruning is done, although the CFG may already be pruned.

Parameters: method the method

Returns: the raw CFG

getReturnPathDataflow

public ReturnPathDataflow getReturnPathDataflow(Method method)
Get ReturnPathDataflow for method.

Parameters: method the method

Returns: the ReturnPathDataflow

getReturnPathTypeDataflow

public ReturnPathTypeDataflow getReturnPathTypeDataflow(Method method)
Get ReturnPathTypeDataflow for a method.

Parameters: method the method

Returns: the ReturnPathTypeDataflow for the method

Throws: CFGBuilderException DataflowAnalysisException

getReverseDepthFirstSearch

public ReverseDepthFirstSearch getReverseDepthFirstSearch(Method method)
Get a ReverseDepthFirstSearch for given method.

Parameters: method the method

Returns: the ReverseDepthFirstSearch

getStoreDataflow

public StoreDataflow getStoreDataflow(Method method)
Get store dataflow.

Parameters: method the method

Returns: the StoreDataflow

Throws: CFGBuilderException DataflowAnalysisException

getTypeDataflow

public TypeDataflow getTypeDataflow(Method method)
Get a TypeDataflow for given method.

Parameters: method the method

Returns: the TypeDataflow

getUnconditionalValueDerefDataflow

public UnconditionalValueDerefDataflow getUnconditionalValueDerefDataflow(Method method)
Get the UnconditionalValueDerefDataflow for a method.

Parameters: method the method

Returns: the UnconditionalValueDerefDataflow

Throws: CFGBuilderException DataflowAnalysisException

getUsagesRequiringNonNullValues

public UsagesRequiringNonNullValues getUsagesRequiringNonNullValues(Method method)
Get a UsagesRequiringNonNullValues for given method.

Parameters: method the method

Returns: the UsagesRequiringNonNullValues

getValueNumberDataflow

public ValueNumberDataflow getValueNumberDataflow(Method method)
Get a ValueNumberDataflow for given method.

Parameters: method the method

Returns: the ValueNumberDataflow

linesMentionedMultipleTimes

public static BitSet linesMentionedMultipleTimes(Method method)
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.