Class FindInconsistentSync2
java.lang.Object
edu.umd.cs.findbugs.detect.FindInconsistentSync2
- All Implemented Interfaces:
Detector, Priorities
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classThe access statistics for a field. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate final BugReporterprivate static final booleanprivate static final booleanprivate static ClassDescriptorprivate static final intprivate static final intMinimum percent of unbiased field accesses that must be synchronized in order to report a field as inconsistently synchronized.private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static ClassDescriptorprivate final Map<XField, FindInconsistentSync2.FieldStats> private static final booleanprivate static final intprivate static final doubleFactor which the biased number of unsynchronized accesses is multiplied by.private static final intprivate static final doubleBias that writes are given with respect to reads.private static final intprivate static final intFields inherited from interface Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidanalyzeMethod(ClassContext classContext, org.apache.bcel.classfile.Method method, Set<org.apache.bcel.classfile.Method> lockedMethodSet) private static Set<org.apache.bcel.classfile.Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) Find methods that appear to always be called from a locked context.private static Set<org.apache.bcel.classfile.Method> findNotUnlockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) Find methods that appear to never be called from an unlocked context We assume that nonpublic methods will only be called from within the class, which is not really a valid assumption.findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls) Find all self-call sites that are obviously locked.private FindInconsistentSync2.FieldStatsGet the access statistics for given field.private static booleanisConstructor(String methodName) static booleanisGetterMethod(ClassContext classContext, org.apache.bcel.classfile.Method method) Determine whether or not the given method is a getter method.static booleanisServletField(XField field) voidreport()This method is called after all classes to be visited.voidvisitClassContext(ClassContext classContext) Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
-
Field Details
-
DEBUG
private static final boolean DEBUG -
SYNC_ACCESS
private static final boolean SYNC_ACCESS- See Also:
-
ADJUST_SUBCLASS_ACCESSES
private static final boolean ADJUST_SUBCLASS_ACCESSES -
EVAL
private static final boolean EVAL -
MIN_SYNC_PERCENT
private static final int MIN_SYNC_PERCENTMinimum percent of unbiased field accesses that must be synchronized in order to report a field as inconsistently synchronized. This is meant to distinguish incidental synchronization from intentional synchronization. -
WRITE_BIAS
private static final double WRITE_BIASBias that writes are given with respect to reads. The idea is that this should be above 1.0, because unsynchronized writes are more dangerous than unsynchronized reads. -
UNSYNC_FACTOR
private static final double UNSYNC_FACTORFactor which the biased number of unsynchronized accesses is multiplied by. I.e., for factor f, if nUnsync is the biased number of unsynchronized accesses, and nSync is the biased number of synchronized accesses, andf(nUnsync) > nSyncthen we report a bug. Default value is 2.0, which means that we report a bug if more than 1/3 of accesses are unsynchronized.Note that
MIN_SYNC_PERCENTalso influences whether we report a bug: it specifies the minimum unbiased percentage of synchronized accesses. -
UNLOCKED
private static final int UNLOCKED- See Also:
-
LOCKED
private static final int LOCKED- See Also:
-
READ
private static final int READ- See Also:
-
WRITE
private static final int WRITE- See Also:
-
NULLCHECK
private static final int NULLCHECK- See Also:
-
READ_UNLOCKED
private static final int READ_UNLOCKED- See Also:
-
WRITE_UNLOCKED
private static final int WRITE_UNLOCKED- See Also:
-
NULLCHECK_UNLOCKED
private static final int NULLCHECK_UNLOCKED- See Also:
-
READ_LOCKED
private static final int READ_LOCKED- See Also:
-
WRITE_LOCKED
private static final int WRITE_LOCKED- See Also:
-
NULLCHECK_LOCKED
private static final int NULLCHECK_LOCKED- See Also:
-
javaxServlet
-
singleThreadedServlet
-
bugReporter
-
statMap
-
-
Constructor Details
-
FindInconsistentSync2
-
-
Method Details
-
isServletField
-
visitClassContext
Description copied from interface:DetectorVisit the ClassContext for a class which should be analyzed for instances of bug patterns.- Specified by:
visitClassContextin interfaceDetector- Parameters:
classContext- the ClassContext
-
report
-
isConstructor
-
analyzeMethod
private void analyzeMethod(ClassContext classContext, org.apache.bcel.classfile.Method method, Set<org.apache.bcel.classfile.Method> lockedMethodSet) throws CFGBuilderException, DataflowAnalysisException -
isGetterMethod
public static boolean isGetterMethod(ClassContext classContext, org.apache.bcel.classfile.Method method) Determine whether or not the given method is a getter method. I.e., if it just returns the value of an instance field.- Parameters:
classContext- the ClassContext for the class containing the methodmethod- the method
-
getStats
Get the access statistics for given field. -
findNotUnlockedMethods
private static Set<org.apache.bcel.classfile.Method> findNotUnlockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) Find methods that appear to never be called from an unlocked context We assume that nonpublic methods will only be called from within the class, which is not really a valid assumption. -
findLockedMethods
private static Set<org.apache.bcel.classfile.Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) Find methods that appear to always be called from a locked context. We assume that nonpublic methods will only be called from within the class, which is not really a valid assumption. -
findObviouslyLockedCallSites
private static Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls) throws CFGBuilderException, DataflowAnalysisException Find all self-call sites that are obviously locked.
-