diff --git a/pom.xml b/pom.xml index 03ff437..b3afaf2 100644 --- a/pom.xml +++ b/pom.xml @@ -175,6 +175,11 @@ mockito-all 1.10.8 + + commons-logging + commons-logging + 1.2 + org.hibernate.javax.persistence diff --git a/src/main/java/jp/co/worksap/oss/findbugs/guava/UnexpectedAccessDetector.java b/src/main/java/jp/co/worksap/oss/findbugs/guava/UnexpectedAccessDetector.java index f88274b..401c53f 100644 --- a/src/main/java/jp/co/worksap/oss/findbugs/guava/UnexpectedAccessDetector.java +++ b/src/main/java/jp/co/worksap/oss/findbugs/guava/UnexpectedAccessDetector.java @@ -8,6 +8,8 @@ import org.apache.bcel.classfile.AnnotationEntry; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import com.google.common.annotations.VisibleForTesting; @@ -29,6 +31,8 @@ public class UnexpectedAccessDetector extends BytecodeScanningDetector { @Nonnull private final BugReporter bugReporter; + private final transient Log log = LogFactory.getLog(this.getClass()); + /** * @param bugReporter */ @@ -68,7 +72,7 @@ void verifyVisibility(ClassDescriptor invokedClass, MethodDescriptor invokedMeth JavaClass bcelClass = Repository.getRepository().loadClass(invokedClass.getDottedClassName()); Method bcelMethod = findMethod(bcelClass, invokedMethod); - if (checkVisibility(bcelMethod) && checkAnnotated(bcelMethod)) { + if (bcelMethod != null && checkVisibility(bcelMethod) && checkAnnotated(bcelMethod)) { BugInstance bug = new BugInstance(this, "GUAVA_UNEXPECTED_ACCESS_TO_VISIBLE_FOR_TESTING", HIGH_PRIORITY); if (reportCaller) { bug.addCalledMethod(this).addClassAndMethod(this).addSourceLine(this); @@ -85,8 +89,8 @@ Method findMethod(JavaClass bcelClass, MethodDescriptor invokedMethod) { return bcelMethod; } } - - throw new IllegalArgumentException("Method not found: " + invokedMethod); + log.warn("Method not found: " + invokedMethod); + return null; } /**