edu.umd.cs.findbugs.ba
Class ClassContext

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.ClassContext

public class ClassContext
extends java.lang.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 boolean DEBUG
           
 
Constructor Summary
ClassContext(org.apache.bcel.classfile.JavaClass jclass, AnalysisContext analysisContext)
          Constructor.
 
Method Summary
 AnalysisContext getAnalysisContext()
          Get the AnalysisContext.
 AssertionMethods getAssertionMethods()
          Get AssertionMethods for class.
 AssignedFieldMap getAssignedFieldMap()
          Get the assigned field map for the class.
 Dataflow<BlockType,BlockTypeAnalysis> getBlockTypeDataflow(org.apache.bcel.classfile.Method method)
          Get BlockType dataflow for given method.
 java.util.BitSet getBytecodeSet(org.apache.bcel.classfile.Method method)
          Get a BitSet representing the bytecodes that are used in the given method.
 CallListDataflow getCallListDataflow(org.apache.bcel.classfile.Method method)
          Get CallListDataflow for method.
 CFG getCFG(org.apache.bcel.classfile.Method method)
          Get a CFG for given method.
 ConstantDataflow getConstantDataflow(org.apache.bcel.classfile.Method method)
          Get ConstantDataflow for method.
 org.apache.bcel.generic.ConstantPoolGen getConstantPoolGen()
          Get the ConstantPoolGen used to create the MethodGens for this class.
 DepthFirstSearch getDepthFirstSearch(org.apache.bcel.classfile.Method method)
          Get a DepthFirstSearch for given method.
 ExceptionSetFactory getExceptionSetFactory(org.apache.bcel.classfile.Method method)
          Get ExceptionSetFactory for given method.
 IsNullValueDataflow getIsNullValueDataflow(org.apache.bcel.classfile.Method method)
          Get an IsNullValueDataflow for given method.
 org.apache.bcel.classfile.JavaClass getJavaClass()
          Get the JavaClass.
 LiveLocalStoreDataflow getLiveLocalStoreDataflow(org.apache.bcel.classfile.Method method)
          Get LiveLocalStoreAnalysis dataflow for given method.
 LoadDataflow getLoadDataflow(org.apache.bcel.classfile.Method method)
          Get load dataflow.
 LoadedFieldSet getLoadedFieldSet(org.apache.bcel.classfile.Method method)
          Get the set of fields loaded by given method.
 LockChecker getLockChecker(org.apache.bcel.classfile.Method method)
          Get LockChecker for method.
 LockDataflow getLockDataflow(org.apache.bcel.classfile.Method method)
          Get dataflow for LockAnalysis for given method.
 RepositoryLookupFailureCallback getLookupFailureCallback()
          Get the RepositoryLookupFailureCallback.
 org.apache.bcel.classfile.Method getMethod(org.apache.bcel.generic.MethodGen methodGen)
          Look up the Method represented by given MethodGen.
 org.apache.bcel.generic.MethodGen getMethodGen(org.apache.bcel.classfile.Method method)
          Get a MethodGen object for given method.
 DominatorsAnalysis getNonExceptionDominatorsAnalysis(org.apache.bcel.classfile.Method method)
          Get DominatorsAnalysis for given method, where exception edges are ignored.
 PostDominatorsAnalysis getNonExceptionPostDominatorsAnalysis(org.apache.bcel.classfile.Method method)
          Get PostDominatorsAnalysis for given method, where exception edges are ignored.
 PostDominatorsAnalysis getNonImplicitExceptionDominatorsAnalysis(org.apache.bcel.classfile.Method method)
          Get DominatorsAnalysis for given method, where implicit exception edges are ignored.
 short[] getOffsetToOpcodeMap(org.apache.bcel.classfile.Method method)
          Get array mapping bytecode offsets to opcodes for given method.
 java.lang.String[] getParameterSignatureList(org.apache.bcel.classfile.Method method)
          Get array of type signatures of parameters for given method.
 CFG getRawCFG(org.apache.bcel.classfile.Method method)
          Get a "raw" CFG for given method.
 ReturnPathDataflow getReturnPathDataflow(org.apache.bcel.classfile.Method method)
          Get ReturnPathDataflow for method.
 ReverseDepthFirstSearch getReverseDepthFirstSearch(org.apache.bcel.classfile.Method method)
          Get a ReverseDepthFirstSearch for given method.
 StoreDataflow getStoreDataflow(org.apache.bcel.classfile.Method method)
          Get store dataflow.
 TypeDataflow getTypeDataflow(org.apache.bcel.classfile.Method method)
          Get a TypeDataflow for given method.
 UnconditionalDerefDataflow getUnconditionalDerefDataflow(org.apache.bcel.classfile.Method method)
          Get the UnconditionalDerefDataflow for a method.
 ValueNumberDataflow getValueNumberDataflow(org.apache.bcel.classfile.Method method)
          Get a ValueNumberDataflow for given method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

ClassContext

public ClassContext(org.apache.bcel.classfile.JavaClass jclass,
                    AnalysisContext analysisContext)
Constructor.

Parameters:
jclass - the JavaClass
Method Detail

getJavaClass

public org.apache.bcel.classfile.JavaClass getJavaClass()
Get the JavaClass.


getMethod

public org.apache.bcel.classfile.Method getMethod(org.apache.bcel.generic.MethodGen methodGen)
Look up the Method represented by given MethodGen.

Parameters:
methodGen - a MethodGen
Returns:
the Method represented by the MethodGen

getAnalysisContext

public AnalysisContext getAnalysisContext()
Get the AnalysisContext.


getLookupFailureCallback

public RepositoryLookupFailureCallback getLookupFailureCallback()
Get the RepositoryLookupFailureCallback.

Returns:
the RepositoryLookupFailureCallback

getMethodGen

@CheckForNull
public org.apache.bcel.generic.MethodGen getMethodGen(org.apache.bcel.classfile.Method method)
Get a MethodGen object for given method.

Parameters:
method - the method
Returns:
the MethodGen object for the method, or null if the method has no Code attribute (and thus cannot be analyzed) or if the method seems unprofitable to analyze

getRawCFG

public CFG getRawCFG(org.apache.bcel.classfile.Method method)
              throws CFGBuilderException
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
Throws:
CFGBuilderException

getCFG

public CFG getCFG(org.apache.bcel.classfile.Method method)
           throws CFGBuilderException
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

getConstantPoolGen

@NonNull
public org.apache.bcel.generic.ConstantPoolGen getConstantPoolGen()
Get the ConstantPoolGen used to create the MethodGens for this class.

Returns:
the ConstantPoolGen

getValueNumberDataflow

public ValueNumberDataflow getValueNumberDataflow(org.apache.bcel.classfile.Method method)
                                           throws DataflowAnalysisException,
                                                  CFGBuilderException
Get a ValueNumberDataflow for given method.

Parameters:
method - the method
Returns:
the ValueNumberDataflow
Throws:
DataflowAnalysisException
CFGBuilderException

getIsNullValueDataflow

public IsNullValueDataflow getIsNullValueDataflow(org.apache.bcel.classfile.Method method)
                                           throws DataflowAnalysisException,
                                                  CFGBuilderException
Get an IsNullValueDataflow for given method.

Parameters:
method - the method
Returns:
the IsNullValueDataflow
Throws:
DataflowAnalysisException
CFGBuilderException

getTypeDataflow

public TypeDataflow getTypeDataflow(org.apache.bcel.classfile.Method method)
                             throws DataflowAnalysisException,
                                    CFGBuilderException
Get a TypeDataflow for given method.

Parameters:
method - the method
Returns:
the TypeDataflow
Throws:
DataflowAnalysisException
CFGBuilderException

getDepthFirstSearch

public DepthFirstSearch getDepthFirstSearch(org.apache.bcel.classfile.Method method)
                                     throws CFGBuilderException
Get a DepthFirstSearch for given method.

Parameters:
method - the method
Returns:
the DepthFirstSearch
Throws:
CFGBuilderException

getReverseDepthFirstSearch

public ReverseDepthFirstSearch getReverseDepthFirstSearch(org.apache.bcel.classfile.Method method)
                                                   throws CFGBuilderException
Get a ReverseDepthFirstSearch for given method.

Parameters:
method - the method
Returns:
the ReverseDepthFirstSearch
Throws:
CFGBuilderException

getBytecodeSet

@CheckForNull
public java.util.BitSet getBytecodeSet(org.apache.bcel.classfile.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

getOffsetToOpcodeMap

public short[] getOffsetToOpcodeMap(org.apache.bcel.classfile.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

getLockDataflow

public LockDataflow getLockDataflow(org.apache.bcel.classfile.Method method)
                             throws CFGBuilderException,
                                    DataflowAnalysisException
Get dataflow for LockAnalysis for given method.

Parameters:
method - the method
Returns:
the LockDataflow
Throws:
CFGBuilderException
DataflowAnalysisException

getLockChecker

public LockChecker getLockChecker(org.apache.bcel.classfile.Method method)
                           throws CFGBuilderException,
                                  DataflowAnalysisException
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

getReturnPathDataflow

public ReturnPathDataflow getReturnPathDataflow(org.apache.bcel.classfile.Method method)
                                         throws CFGBuilderException,
                                                DataflowAnalysisException
Get ReturnPathDataflow for method.

Parameters:
method - the method
Returns:
the ReturnPathDataflow
Throws:
CFGBuilderException
DataflowAnalysisException

getNonExceptionDominatorsAnalysis

public DominatorsAnalysis getNonExceptionDominatorsAnalysis(org.apache.bcel.classfile.Method method)
                                                     throws CFGBuilderException,
                                                            DataflowAnalysisException
Get DominatorsAnalysis for given method, where exception edges are ignored.

Parameters:
method - the method
Returns:
the DominatorsAnalysis
Throws:
CFGBuilderException
DataflowAnalysisException

getNonImplicitExceptionDominatorsAnalysis

public PostDominatorsAnalysis getNonImplicitExceptionDominatorsAnalysis(org.apache.bcel.classfile.Method method)
                                                                 throws CFGBuilderException,
                                                                        DataflowAnalysisException
Get DominatorsAnalysis for given method, where implicit exception edges are ignored.

Parameters:
method - the method
Returns:
the DominatorsAnalysis
Throws:
CFGBuilderException
DataflowAnalysisException

getNonExceptionPostDominatorsAnalysis

public PostDominatorsAnalysis getNonExceptionPostDominatorsAnalysis(org.apache.bcel.classfile.Method method)
                                                             throws CFGBuilderException,
                                                                    DataflowAnalysisException
Get PostDominatorsAnalysis for given method, where exception edges are ignored.

Parameters:
method - the method
Returns:
the PostDominatorsAnalysis
Throws:
CFGBuilderException
DataflowAnalysisException

getExceptionSetFactory

public ExceptionSetFactory getExceptionSetFactory(org.apache.bcel.classfile.Method method)
Get ExceptionSetFactory for given method.

Parameters:
method - the method
Returns:
the ExceptionSetFactory

getParameterSignatureList

public java.lang.String[] getParameterSignatureList(org.apache.bcel.classfile.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

getLoadedFieldSet

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

Parameters:
method - the method
Returns:
the set of fields loaded by the method

getLiveLocalStoreDataflow

public LiveLocalStoreDataflow getLiveLocalStoreDataflow(org.apache.bcel.classfile.Method method)
                                                 throws DataflowAnalysisException,
                                                        CFGBuilderException
Get LiveLocalStoreAnalysis dataflow for given method.

Parameters:
method - the method
Returns:
the Dataflow object for LiveLocalStoreAnalysis on the method
Throws:
DataflowAnalysisException
CFGBuilderException

getBlockTypeDataflow

public Dataflow<BlockType,BlockTypeAnalysis> getBlockTypeDataflow(org.apache.bcel.classfile.Method method)
                                                           throws DataflowAnalysisException,
                                                                  CFGBuilderException
Get BlockType dataflow for given method.

Parameters:
method - the method
Returns:
the Dataflow object for BlockTypeAnalysis on the method
Throws:
DataflowAnalysisException
CFGBuilderException

getAssignedFieldMap

public AssignedFieldMap getAssignedFieldMap()
                                     throws java.lang.ClassNotFoundException
Get the assigned field map for the class.

Returns:
the AssignedFieldMap
Throws:
java.lang.ClassNotFoundException - if a class lookup prevents the class's superclasses from being searched for assignable fields

getAssertionMethods

public AssertionMethods getAssertionMethods()
Get AssertionMethods for class.

Returns:
the AssertionMethods

getConstantDataflow

public ConstantDataflow getConstantDataflow(org.apache.bcel.classfile.Method method)
                                     throws CFGBuilderException,
                                            DataflowAnalysisException
Get ConstantDataflow for method.

Parameters:
method - the method
Returns:
the ConstantDataflow
Throws:
CFGBuilderException
DataflowAnalysisException

getUnconditionalDerefDataflow

public UnconditionalDerefDataflow getUnconditionalDerefDataflow(org.apache.bcel.classfile.Method method)
                                                         throws CFGBuilderException,
                                                                DataflowAnalysisException
Get the UnconditionalDerefDataflow for a method.

Parameters:
method - the method
Returns:
the UnconditionalDerefDataflow for the method
Throws:
CFGBuilderException
DataflowAnalysisException

getLoadDataflow

public LoadDataflow getLoadDataflow(org.apache.bcel.classfile.Method method)
                             throws CFGBuilderException,
                                    DataflowAnalysisException
Get load dataflow.

Parameters:
method - the method
Returns:
the LoadDataflow
Throws:
CFGBuilderException
DataflowAnalysisException

getStoreDataflow

public StoreDataflow getStoreDataflow(org.apache.bcel.classfile.Method method)
                               throws CFGBuilderException,
                                      DataflowAnalysisException
Get store dataflow.

Parameters:
method - the method
Returns:
the StoreDataflow
Throws:
CFGBuilderException
DataflowAnalysisException

getCallListDataflow

public CallListDataflow getCallListDataflow(org.apache.bcel.classfile.Method method)
                                     throws CFGBuilderException,
                                            DataflowAnalysisException
Get CallListDataflow for method.

Parameters:
method - the method
Returns:
the CallListDataflow
Throws:
CFGBuilderException
DataflowAnalysisException