@Override
 public void visit(Code obj) {
   sawSuperFinalize = false;
   super.visit(obj);
   bugAccumulator.reportAccumulatedBugs();
   if (!getMethodName().equals("finalize") || !getMethodSig().equals("()V")) return;
   String overridesFinalizeIn =
       Lookup.findSuperImplementor(getDottedClassName(), "finalize", "()V", bugReporter);
   boolean superHasNoFinalizer = overridesFinalizeIn.equals("java.lang.Object");
   // System.out.println("superclass: " + superclassName);
   if (obj.getCode().length == 1) {
     if (superHasNoFinalizer) {
       if (!getMethod().isFinal())
         bugReporter.reportBug(
             new BugInstance(this, "FI_EMPTY", NORMAL_PRIORITY).addClassAndMethod(this));
     } else
       bugReporter.reportBug(
           new BugInstance(this, "FI_NULLIFY_SUPER", NORMAL_PRIORITY)
               .addClassAndMethod(this)
               .addClass(overridesFinalizeIn));
   } else if (obj.getCode().length == 5 && sawSuperFinalize)
     bugReporter.reportBug(
         new BugInstance(this, "FI_USELESS", NORMAL_PRIORITY).addClassAndMethod(this));
   else if (!sawSuperFinalize && !superHasNoFinalizer)
     bugReporter.reportBug(
         new BugInstance(this, "FI_MISSING_SUPER_CALL", NORMAL_PRIORITY)
             .addClassAndMethod(this)
             .addClass(overridesFinalizeIn));
 }
Пример #2
0
 @Override
 public void visit(Code obj) {
   if (!directChildOfTestCase
       && (getMethodName().equals("setUp") || getMethodName().equals("tearDown"))
       && !getMethod().isPrivate()
       && getMethodSig().equals("()V")) {
     sawSuperCall = false;
     super.visit(obj);
     if (sawSuperCall) {
       return;
     }
     JavaClass we =
         Lookup.findSuperImplementor(getThisClass(), getMethodName(), "()V", bugReporter);
     if (we != null && !we.getClassName().equals("junit.framework.TestCase")) {
       // OK, got a bug
       int offset = 0;
       if (getMethodName().equals("tearDown")) {
         offset = obj.getCode().length - 1;
       }
       Method superMethod = Lookup.findImplementation(we, getMethodName(), "()V");
       Code superCode = superMethod.getCode();
       if (superCode != null && superCode.getCode().length > 3) {
         bugReporter.reportBug(
             new BugInstance(
                     this,
                     getMethodName().equals("setUp")
                         ? "IJU_SETUP_NO_SUPER"
                         : "IJU_TEARDOWN_NO_SUPER",
                     NORMAL_PRIORITY)
                 .addClassAndMethod(this)
                 .addMethod(we, superMethod)
                 .describe(MethodAnnotation.METHOD_OVERRIDDEN)
                 .addSourceLine(this, offset));
       }
     }
   }
 }
Пример #3
0
 @Override
 public void visit(Code obj) {
   if (inConstructor) {
     super.visit(obj);
   }
 }
 @Override
 public void visit(Code obj) {
   super.visit(obj);
   bugAccumulator.reportAccumulatedBugs();
 }
 @Override
 public void visit(Method obj) {
   localsWithCurrentThreadValue = new BitSet();
   state = SEEN_NOTHING;
   super.visit(obj);
 }
 @Override
 public void visit(Code code) {
   binpushPC = Integer.MIN_VALUE;
   numCompareBlockStartPC = 0;
   super.visit(code);
 }