/** is there a JUnit3TestSuite */ private boolean hasSuite(Method[] methods) { for (Method m : methods) { if (m.getName().equals("suite") && m.isPublic() && m.isStatic() // && m.getReturnType().equals(junit.framework.Test.class) // && m.getArgumentTypes().length == 0 && m.getSignature().equals("()Ljunit/framework/Test;")) { return true; } } return false; }
@Override public void visit(Method method) { if(method.isPublic() && "next".equals(method.getName()) && method.getArgumentTypes().length == 0){ shouldVisitCode = true; super.visit(method); } else { shouldVisitCode = false; } }
@Override public void visit(Method obj) { if (DEBUG) { System.out.println("Checking " + getClassName() + "." + obj.getName()); } if (Const.CONSTRUCTOR_NAME.equals(getMethodName()) && (obj.isPublic() || obj.isProtected())) { publicOrProtectedConstructor = true; } pendingGetField = null; saState = 0; super.visit(obj); int flags = obj.getAccessFlags(); if ((flags & Const.ACC_NATIVE) != 0) { hasNativeMethods = true; } }
@Override public void visit(Method method) { String cName = getDottedClassName(); for(SubDetector subDetector : subDetectors) { subDetector.initMethod(method); } // System.out.println(getFullyQualifiedMethodName()); isPublicStaticVoidMain = method.isPublic() && method.isStatic() && "main".equals(getMethodName()) || cName.toLowerCase().indexOf("benchmark") >= 0; prevOpcodeWasReadLine = false; Code code = method.getCode(); if (code != null) { this.exceptionTable = code.getExceptionTable(); } if (this.exceptionTable == null) { this.exceptionTable = new CodeException[0]; } primitiveObjCtorSeen = null; ctorSeen = false; randomNextIntState = 0; checkForBitIorofSignedByte = false; sinceBufferedInputStreamReady = 100000; sawCheckForNonNegativeSignedByte = -1000; sawLoadOfMinValue = false; previousMethodCall = null; }
@Override public void visit(Code obj) { if (Const.CONSTRUCTOR_NAME.equals(getMethodName()) && (getMethod().isPublic() || getMethod().isProtected())) { super.visit(obj); bugAccumulator.reportAccumulatedBugs(); } }
@Override public void visit(Method obj) { if (getMethodName().equals("suite") && !obj.isStatic()) { bugReporter.reportBug(new BugInstance(this, "IJU_SUITE_NOT_STATIC", NORMAL_PRIORITY).addClassAndMethod(this)); } if (getMethodName().equals("suite") && obj.getSignature().startsWith("()") && obj.isStatic()) { if ((!obj.getSignature().equals("()Ljunit/framework/Test;") && !obj.getSignature().equals( "()Ljunit/framework/TestSuite;")) || !obj.isPublic()) { bugReporter.reportBug(new BugInstance(this, "IJU_BAD_SUITE_METHOD", NORMAL_PRIORITY).addClassAndMethod(this)); } } }
private boolean hasTestMethods(JavaClass jClass) { boolean foundTest = false; Method[] methods = jClass.getMethods(); for (Method m : methods) { if (m.isPublic() && m.getName().startsWith("test") && m.getSignature().equals("()V")) { return true; } if (m.getName().startsWith("runTest") && m.getSignature().endsWith("()V")) { return true; } } if (hasSuite(methods)) { return true; } try { JavaClass sClass = jClass.getSuperClass(); if (sClass != null) { return hasTestMethods(sClass); } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } return false; }
if (method.isPublic() && !isConstructor(method.getName())) { lockedMethodSet.remove(method);
@Override public void visit(Code obj) { if (!getMethod().isPublic() && !getMethod().isProtected()) { return;
@Override public void visit(Method obj) { if (obj.isAbstract() || BCELUtil.isSynthetic(obj)) { return; } if (!obj.isPublic()) { return; } if (!"clone".equals(getMethodName())) { return; } if (!getMethodSig().startsWith("()")) { return; } hasCloneMethod = true; cloneIsDeprecated = getXMethod().isDeprecated(); cloneMethodAnnotation = MethodAnnotation.fromVisitedMethod(this); cloneOnlyThrowsException = PruneUnconditionalExceptionThrowerEdges.doesMethodUnconditionallyThrowException(XFactory .createXMethod(this)); // ExceptionTable tbl = obj.getExceptionTable(); // throwsExceptions = tbl != null && tbl.getNumberOfExceptions() > 0; }
} else if (obj.isPublic() && "equals".equals(name)) { Matcher m = predicateOverAnInstance.matcher(sig); if (m.matches()) {
@Override public void visit(Code obj) { if (EQUALS_NAME.equals(getMethodName()) && !getMethod().isStatic() && getMethod().isPublic() && EQUALS_SIGNATURE.equals(getMethodSig())) { sawCheckedCast = sawSuperEquals = sawInstanceOf = sawGetClass = sawReturnSuper = sawCompare = sawReturnNonSuper = prevWasSuperEquals = sawGoodEqualsClass = sawBadEqualsClass = dangerDanger = sawInstanceOfSupertype = alwaysTrue = alwaysFalse = sawStaticDelegate = sawEqualsBuilder = false;
if (method.isPublic()) { priority = NORMAL_PRIORITY; } else if (method.isProtected() || isDefaultAccess) {
priority--; if (getThisClass().isPublic() && getMethod().isPublic()) { priority--;
int priority = method.isPublic() ? NORMAL_PRIORITY : LOW_PRIORITY;
/** is there a JUnit3TestSuite */ private boolean hasSuite(Method[] methods) { for (Method m : methods) { if (m.getName().equals("suite") && m.isPublic() && m.isStatic() // && m.getReturnType().equals(junit.framework.Test.class) // && m.getArgumentTypes().length == 0 && m.getSignature().equals("()Ljunit/framework/Test;")) { return true; } } return false; }
@Override public void visit(Method method) { if(method.isPublic() && "next".equals(method.getName()) && method.getArgumentTypes().length == 0){ shouldVisitCode = true; super.visit(method); } else { shouldVisitCode = false; } }
@Override public void visit(Code obj) { if ("<init>".equals(getMethodName()) && (getMethod().isPublic() || getMethod().isProtected())) { super.visit(obj); bugAccumulator.reportAccumulatedBugs(); } }
public boolean isLoader(ClassGen cg) { return cg.getMethods().length == 3 && cg.getMethods()[1].isStatic() && cg.getMethods()[1].isFinal() && cg.getMethods()[1].isPublic() && cg.getMethods()[1].isSynchronized() && cg.getMethods()[1].getReturnType().toString().equals("java.lang.String"); }