Package edu.umd.cs.findbugs.ba
Class ClassContext
java.lang.Object
edu.umd.cs.findbugs.ba.ClassContext
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
FieldsModifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionClassContext
(org.apache.bcel.classfile.JavaClass jclass, AnalysisContext analysisContext) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dumpDataflowInformation
(org.apache.bcel.classfile.Method method) static void
dumpDataflowInformation
(org.apache.bcel.classfile.Method method, CFG cfg, ValueNumberDataflow vnd, IsNullValueDataflow inv, UnconditionalValueDerefDataflow dataflow, TypeDataflow typeDataflow) static void
dumpLiveLocalStoreDataflow
(MethodDescriptor method, CFG cfg, LiveLocalStoreDataflow dataflow) void
dumpSimpleDataflowInformation
(org.apache.bcel.classfile.Method method) static void
dumpTypeDataflow
(org.apache.bcel.classfile.Method method, CFG cfg, TypeDataflow typeDataflow) Get the AnalysisContext.Get AssertionMethods for class.getBlockTypeDataflow
(org.apache.bcel.classfile.Method method) Get BlockType dataflow for given method.static BitSet
getBytecodeSet
(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Method method) Get a BitSet representing the bytecodes that are used in the given method.getBytecodeSet
(org.apache.bcel.classfile.Method method) Get a BitSet representing the bytecodes that are used in the given method.getCallListDataflow
(org.apache.bcel.classfile.Method method) Get CallListDataflow for method.getCFG
(org.apache.bcel.classfile.Method method) Get a CFG for given method.getCompactLocationNumbering
(org.apache.bcel.classfile.Method method) Get a CompactLocationNumbering for a method.getConstantDataflow
(org.apache.bcel.classfile.Method method) Get ConstantDataflow for method.org.apache.bcel.generic.ConstantPoolGen
Get the ConstantPoolGen used to create the MethodGens for this class.getDepthFirstSearch
(org.apache.bcel.classfile.Method method) Get a DepthFirstSearch for given method.getExceptionSetFactory
(org.apache.bcel.classfile.Method method) Get ExceptionSetFactory for given method.getFullyQualifiedMethodName
(org.apache.bcel.classfile.Method method) getIsNullValueDataflow
(org.apache.bcel.classfile.Method method) Get an IsNullValueDataflow for given method.org.apache.bcel.classfile.JavaClass
Get the JavaClass.getLiveLocalStoreDataflow
(org.apache.bcel.classfile.Method method) Get LiveLocalStoreAnalysis dataflow for given method.getLoadDataflow
(org.apache.bcel.classfile.Method method) Get load dataflow.getLoadedFieldSet
(org.apache.bcel.classfile.Method method) Get the set of fields loaded by given method.getLockChecker
(org.apache.bcel.classfile.Method method) Get LockChecker for method.getLockDataflow
(org.apache.bcel.classfile.Method method) Get dataflow for LockAnalysis for given method.Get the RepositoryLookupFailureCallback.getLoopExitBranches
(org.apache.bcel.classfile.Method method, org.apache.bcel.generic.MethodGen methodGen) org.apache.bcel.classfile.Method
getMethod
(org.apache.bcel.generic.MethodGen methodGen) Look up the Method represented by given MethodGen.getMethodAnalysis
(Class<?> analysisClass, MethodDescriptor methodDescriptor) Retrieve a method analysis object.org.apache.bcel.generic.MethodGen
getMethodGen
(org.apache.bcel.classfile.Method method) Get a MethodGen object for given method.List
<org.apache.bcel.classfile.Method> getNonExceptionDominatorsAnalysis
(org.apache.bcel.classfile.Method method) Get DominatorsAnalysis for given method, where exception edges are ignored.getNonExceptionPostDominatorsAnalysis
(org.apache.bcel.classfile.Method method) Get PostDominatorsAnalysis for given method, where exception edges are ignored.getNonImplicitExceptionDominatorsAnalysis
(org.apache.bcel.classfile.Method method) Get DominatorsAnalysis for given method, where implicit exception edges are ignored.getNonImplicitExceptionPostDominatorsAnalysis
(org.apache.bcel.classfile.Method method) Get PostDominatorsAnalysis for given method, where implicit exception edges are ignored.getObjectMap
(Class<?> analysisClass) short[]
getOffsetToOpcodeMap
(org.apache.bcel.classfile.Method method) Get array mapping bytecode offsets to opcodes for given method.String[]
getParameterSignatureList
(org.apache.bcel.classfile.Method method) Get array of type signatures of parameters for given method.getReturnPathDataflow
(org.apache.bcel.classfile.Method method) Get ReturnPathDataflow for method.getReturnPathTypeDataflow
(org.apache.bcel.classfile.Method method) Get ReturnPathTypeDataflow for a method.getReverseDepthFirstSearch
(org.apache.bcel.classfile.Method method) Get a ReverseDepthFirstSearch for given method.getStoreDataflow
(org.apache.bcel.classfile.Method method) Get store dataflow.getTypeDataflow
(org.apache.bcel.classfile.Method method) Get a TypeDataflow for given method.getUnconditionalValueDerefDataflow
(org.apache.bcel.classfile.Method method) Get the UnconditionalValueDerefDataflow for a method.getUsagesRequiringNonNullValues
(org.apache.bcel.classfile.Method method) Get a UsagesRequiringNonNullValues for given method.getValueNumberDataflow
(org.apache.bcel.classfile.Method method) Get a ValueNumberDataflow for given method.linesMentionedMultipleTimes
(org.apache.bcel.classfile.Method method) void
void
purgeMethodAnalyses
(MethodDescriptor methodDescriptor) Purge all CFG-based method analyses for given method.void
putMethodAnalysis
(Class<?> analysisClass, MethodDescriptor methodDescriptor, Object object) Store a method analysis object.toString()
-
Field Details
-
DEBUG
public static final boolean DEBUG -
TIME_ANALYSES
public static final boolean TIME_ANALYSES -
DUMP_DATAFLOW_ANALYSIS
public static final boolean DUMP_DATAFLOW_ANALYSIS
-
-
Constructor Details
-
ClassContext
Constructor.- Parameters:
jclass
- the JavaClass
-
-
Method Details
-
toString
-
getObjectMap
-
putMethodAnalysis
public void putMethodAnalysis(Class<?> analysisClass, MethodDescriptor methodDescriptor, Object object) Store a method analysis object. Note that the cached analysis object could be a special value (indicating null or an exception).- Parameters:
analysisClass
- class the method analysis object belongs tomethodDescriptor
- method descriptor identifying the analyzed methodobject
- the analysis object to cache
-
getMethodAnalysis
Retrieve a method analysis object.- Parameters:
analysisClass
- class the method analysis object should belong tomethodDescriptor
- method descriptor identifying the analyzed method- Returns:
- the analysis object
-
purgeAllMethodAnalyses
public void purgeAllMethodAnalyses() -
purgeMethodAnalyses
Purge all CFG-based method analyses for given method.- Parameters:
methodDescriptor
- method descriptor identifying method to purge
-
getJavaClass
public org.apache.bcel.classfile.JavaClass getJavaClass()Get the JavaClass. -
getXClass
-
getClassDescriptor
-
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
-
getFullyQualifiedMethodName
-
getMethodsInCallOrder
-
getAnalysisContext
Get the AnalysisContext. -
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
-
getCFG
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
-
getUsagesRequiringNonNullValues
public UsagesRequiringNonNullValues getUsagesRequiringNonNullValues(org.apache.bcel.classfile.Method method) throws DataflowAnalysisException, CFGBuilderException Get a UsagesRequiringNonNullValues for given method.- Parameters:
method
- the method- Returns:
- the UsagesRequiringNonNullValues
- Throws:
DataflowAnalysisException
CFGBuilderException
-
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
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
-
getBytecodeSet
@CheckForNull public static BitSet getBytecodeSet(org.apache.bcel.classfile.JavaClass clazz, 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
-
getLoopExitBranches
-
getOffsetToOpcodeMap
@Nonnull 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, empty 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 DominatorsAnalysis 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
-
getNonImplicitExceptionPostDominatorsAnalysis
public PostDominatorsAnalysis getNonImplicitExceptionPostDominatorsAnalysis(org.apache.bcel.classfile.Method method) throws CFGBuilderException, DataflowAnalysisException Get PostDominatorsAnalysis for given method, where implicit exception edges are ignored.- Parameters:
method
- the method- Returns:
- the PostDominatorsAnalysis
- Throws:
CFGBuilderException
DataflowAnalysisException
-
getExceptionSetFactory
Get ExceptionSetFactory for given method.- Parameters:
method
- the method- Returns:
- the ExceptionSetFactory
-
getParameterSignatureList
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
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 BlockTypeDataflow 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
-
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
-
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
-
linesMentionedMultipleTimes
-
getUnconditionalValueDerefDataflow
public UnconditionalValueDerefDataflow getUnconditionalValueDerefDataflow(org.apache.bcel.classfile.Method method) throws CFGBuilderException, DataflowAnalysisException Get the UnconditionalValueDerefDataflow for a method.- Parameters:
method
- the method- Returns:
- the UnconditionalValueDerefDataflow
- Throws:
CFGBuilderException
DataflowAnalysisException
-
getCompactLocationNumbering
public CompactLocationNumbering getCompactLocationNumbering(org.apache.bcel.classfile.Method method) throws CFGBuilderException Get a CompactLocationNumbering for a method.- Parameters:
method
- a method- Returns:
- the CompactLocationNumbering for the method
- Throws:
CFGBuilderException
-
getReturnPathTypeDataflow
public ReturnPathTypeDataflow getReturnPathTypeDataflow(org.apache.bcel.classfile.Method method) throws CFGBuilderException, DataflowAnalysisException Get ReturnPathTypeDataflow for a method.- Parameters:
method
- the method- Returns:
- the ReturnPathTypeDataflow for the method
- Throws:
CFGBuilderException
DataflowAnalysisException
-
dumpSimpleDataflowInformation
public void dumpSimpleDataflowInformation(org.apache.bcel.classfile.Method method) -
dumpDataflowInformation
public void dumpDataflowInformation(org.apache.bcel.classfile.Method method) -
dumpDataflowInformation
public static void dumpDataflowInformation(org.apache.bcel.classfile.Method method, CFG cfg, ValueNumberDataflow vnd, IsNullValueDataflow inv, @CheckForNull UnconditionalValueDerefDataflow dataflow, @CheckForNull TypeDataflow typeDataflow) throws DataflowAnalysisException - Throws:
DataflowAnalysisException
-
dumpTypeDataflow
public static void dumpTypeDataflow(org.apache.bcel.classfile.Method method, CFG cfg, TypeDataflow typeDataflow) throws DataflowAnalysisException - Throws:
DataflowAnalysisException
-
dumpLiveLocalStoreDataflow
public static void dumpLiveLocalStoreDataflow(MethodDescriptor method, CFG cfg, LiveLocalStoreDataflow dataflow) throws DataflowAnalysisException - Throws:
DataflowAnalysisException
-