/**
   * checks to see if it this class has unit test related annotations attached to methods
   *
   * @param cls the class to check
   * @return if a unit test annotation was found
   */
  private static boolean isTestClass(JavaClass cls) {
    for (Method m : cls.getMethods()) {
      for (AnnotationEntry entry : m.getAnnotationEntries()) {
        String type = entry.getAnnotationType();
        if (type.startsWith("Lorg/junit/") || type.startsWith("Lorg/testng/")) {
          return true;
        }
      }
    }

    return false;
  }
Exemple #2
0
  /** Creates a new method info. */
  protected MethodInfo(Method m, ClassInfo c) {
    name = m.getName();
    signature = m.getSignature();
    ci = c;

    code = loadCode(m);
    exceptions = loadExceptions(m);
    thrownExceptionClassNames = loadThrownExceptionClassNames(m);
    lineNumbers = loadLineNumbers(m);
    maxLocals = getMaxLocals(m);
    maxStack = getMaxStack(m);
    localVariableNames = loadLocalVariableNames(m);
    localVariableTypes = loadLocalVariableTypes(m);

    modifiers = m.getModifiers();

    // clinits are automatically synchronized on the class object,
    // and they don't let unhandled exceptions through
    if (name.equals("<clinit>")) {
      modifiers |= Modifier.SYNCHRONIZED;
      attrs |= IS_CLINIT | FIREWALL;
    }

    if (name.equals("<init>")) {
      attrs |= IS_INIT;
    }

    if (c.isInterface()) { // all interface methods are public
      modifiers |= Modifier.PUBLIC;
    }

    // since that's used to store the method in the ClassInfo, and to
    // identify it in tne InvokeInstruction, we can set it here
    uniqueName = getUniqueName(name, signature);

    globalId = mthTable.size();
    mthTable.add(this);

    loadAnnotations(m.getAnnotationEntries());
    loadParameterAnnotations(m);
  }