Skip to content
Permalink
Browse files

Merge branch 'findbugs' into spotbugs

  • Loading branch information...
mebigfatguy committed Oct 3, 2019
2 parents 72bd492 + 75a9e15 commit 898323a3d3f709000f7c616548944f802058d10e
@@ -24,7 +24,7 @@
<AuxClasspathEntry>././../lib/testng-6.9.10.jar</AuxClasspathEntry>
<AuxClasspathEntry>././../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry>
<AuxClasspathEntry>././../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry>
<AuxClasspathEntry>././../lib/mockito-core-2.8.47.jar</AuxClasspathEntry>
<AuxClasspathEntry>././../lib/mockito-core-2.23.4.jar</AuxClasspathEntry>
<AuxClasspathEntry>././../lib/hamcrest-core-1.3.jar</AuxClasspathEntry>
<AuxClasspathEntry>./../lib/log4j-api-2.9.1.jar</AuxClasspathEntry>
<AuxClasspathEntry>../lib/hamcrest-library-1.3.jar</AuxClasspathEntry>
@@ -43,6 +43,7 @@
import edu.umd.cs.findbugs.NonReportingDetector;
import edu.umd.cs.findbugs.OpcodeStack;
import edu.umd.cs.findbugs.ba.ClassContext;
import edu.umd.cs.findbugs.ba.SignatureParser;

/**
* a first pass detector to collect various statistics used in second pass detectors.
@@ -146,7 +147,7 @@ public void visitCode(Code obj) {
boolean isDerived = false;
if (!constrainingMethods.isEmpty()) {
QMethod qm = new QMethod(method.getName(), method.getSignature());
isDerived = constrainingMethods.contains(qm);
isDerived = isConstrained(qm);
}

MethodInfo mi = Statistics.getStatistics().addMethodStatistics(clsName, getMethodName(), getMethodSig(), accessFlags, code.length,
@@ -302,6 +303,48 @@ private boolean isAssociationedWithAnnotations(Method m) {

return constraints;
}

private boolean isConstrained(QMethod m) {
if (constrainingMethods.contains(m)) {
return true;
}

SignatureParser mp = new SignatureParser(m.getSignature());
int numParms = mp.getNumParameters();

for (QMethod constraint : constrainingMethods) {
if (m.getMethodName().equals(constraint.getMethodName())) {
SignatureParser cp = new SignatureParser(constraint.getSignature());
if (numParms == cp.getNumParameters()) {
String[] mParms = mp.getArguments();
String[] cParms = cp.getArguments();

boolean matches = true;
for (int i = 0; i < numParms; i++) {
if (Values.SIG_JAVA_LANG_OBJECT.equals(cParms[i])) {
matches = mParms[i].charAt(0) == 'L';
} else {
matches = cParms[i].equals(mParms[i]);
}
}
if (matches) {
if (Values.SIG_JAVA_LANG_OBJECT.equals(cp.getReturnTypeSignature())) {
matches = mp.getReturnTypeSignature().charAt(0) == 'L';
} else {
matches =cp.getReturnTypeSignature().equals(mp.getReturnTypeSignature());
}
}

if (matches) {
return true;
}
}

}
}

return false;
}

/**
* represents a method that is called, and whether it is in the super class
@@ -129,4 +129,17 @@ private static Object create() {
}
return Collections.singletonList(s);
}

interface GenericI<X> {
X useGeneric();
}

static class GenericClass implements GenericI<String> {

public String useGeneric() {
return null;
}
}


}

0 comments on commit 898323a

Please sign in to comment.
You can’t perform that action at this time.