@@ -94,25 +94,30 @@ public void sawOpcode(int seen) {
94
94
95
95
if (firstPass ) {
96
96
collectMethodsUsedInThreads (seen );
97
- } else {
97
+ } /* else {
98
98
try {
99
99
collectFieldsUsedInThreads(seen);
100
100
} catch (CheckedAnalysisException e) {
101
101
bugReporter.logError(String.format("Detector %s caught exception while analyzing class %s", getClass().getName(), getClassName()), e);
102
102
}
103
- }
103
+ }*/
104
104
}
105
105
106
106
private void collectMethodsUsedInThreads (int seen ) {
107
107
if (seen == Const .INVOKEDYNAMIC && getStack ().getStackDepth () > 1
108
108
&& "Ljava/lang/Thread;" .equals (getStack ().getStackItem (1 ).getSignature ())
109
109
&& !isJavaRuntimeMethod ()) {
110
- getMethodFromBootstrap (getThisClass (), (ConstantInvokeDynamic ) getConstantRefOperand ()).ifPresent (methodsUsedInThreads ::add );
111
- } else if ((seen == Const .INVOKEVIRTUAL || seen == Const .INVOKEINTERFACE || seen == Const .INVOKESPECIAL || seen == Const .INVOKESTATIC )
110
+ getMethodFromBootstrap (getThisClass (), (ConstantInvokeDynamic ) getConstantRefOperand ()).ifPresent (methodDescriptor -> {
111
+ BugInstance bug = new BugInstance (this , "AT_UNSAFE_RESOURCE_ACCESS_IN_THREAD" , LOW_PRIORITY )
112
+ .addClass (this )
113
+ .addMethod (methodDescriptor );
114
+ bugReporter .reportBug (bug );
115
+ });
116
+ } /*else if ((seen == Const.INVOKEVIRTUAL || seen == Const.INVOKEINTERFACE || seen == Const.INVOKESPECIAL || seen == Const.INVOKESTATIC)
112
117
&& getXMethodOperand() != null && methodsUsedInThreads.contains(getMethodDescriptor())
113
118
&& getClassDescriptor().equals(getXMethodOperand().getClassDescriptor())) {
114
119
methodsUsedInThreads.add(getMethodDescriptorOperand());
115
- }
120
+ }*/
116
121
}
117
122
118
123
/**
@@ -187,12 +192,12 @@ private void createOrUpdateFieldData(XField xField, boolean putfield, Method met
187
192
188
193
@ Override
189
194
public void visitAfter (JavaClass javaClass ) {
190
- super .visit (javaClass );
191
- fieldsUsedInThreads .entrySet ().stream ()
192
- .filter (entry -> isBug (entry .getValue ()))
193
- .flatMap (entry -> entry .getValue ().methodBugs .values ().stream ().flatMap (Set ::stream ))
194
- .collect (Collectors .toSet ())
195
- .forEach (bugReporter ::reportBug );
195
+ // super.visit(javaClass);
196
+ // fieldsUsedInThreads.entrySet().stream()
197
+ // .filter(entry -> isBug(entry.getValue()))
198
+ // .flatMap(entry -> entry.getValue().methodBugs.values().stream().flatMap(Set::stream))
199
+ // .collect(Collectors.toSet())
200
+ // .forEach(bugReporter::reportBug);
196
201
}
197
202
198
203
/**
0 commit comments