Skip to content

Commit abb4908

Browse files
committed
Count interested atomic fields
1 parent 6063fe3 commit abb4908

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

spotbugs/src/main/java/edu/umd/cs/findbugs/detect/AtomicOperationsCombinedDetector.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ public void visitClassContext(ClassContext classContext) {
119119
for (Method method : classContext.getMethodsInCallOrder()) {
120120
collectFieldsForAtomicityCheck(classContext, method);
121121
}
122-
for (Method method : classContext.getMethodsInCallOrder()) {
123-
analyzeFieldsForAtomicityViolations(classContext, method);
124-
}
125-
removePresynchronizedPrivateMethodCalls();
126-
accumulateFieldsForAtomicityAnalysis();
127-
accumulateLocalVariables();
122+
//for (Method method : classContext.getMethodsInCallOrder()) {
123+
// analyzeFieldsForAtomicityViolations(classContext, method);
124+
//}
125+
//removePresynchronizedPrivateMethodCalls();
126+
//accumulateFieldsForAtomicityAnalysis();
127+
//accumulateLocalVariables();
128128
} catch (CheckedAnalysisException e) {
129129
bugReporter.logError(String.format("Detector %s caught exception while analyzing class %s",
130130
getClass().getName(), classContext.getJavaClass().getClassName()), e);
@@ -145,7 +145,11 @@ private void collectFieldsForAtomicityCheck(ClassContext classContext, Method me
145145
OpcodeStack stack = OpcodeStackScanner.getStackAt(classContext.getJavaClass(), method, handle.getPosition());
146146
OpcodeStack.Item stackItem = stack.getStackItem(0);
147147
if (isAtomicField(stackItem.getReturnValueOf())) {
148-
fieldsForAtomicityCheck.add(XFactory.createXField((FieldInstruction) instruction, cpg));
148+
//fieldsForAtomicityCheck.add(XFactory.createXField((FieldInstruction) instruction, cpg));
149+
BugPrototype bugPrototype = new BugPrototype(classContext, method, location);
150+
bugPrototype.invokedField = XFactory.createXField((FieldInstruction) instruction, cpg);
151+
BugInstance bugInstance = bugPrototype.toBugInstance(this, "AT_COMBINED_ATOMIC_OPERATIONS_ARE_NOT_ATOMIC");
152+
bugAccumulator.accumulateBug(bugInstance, bugInstance.getPrimarySourceLineAnnotation());
149153
}
150154
}
151155
}

0 commit comments

Comments
 (0)