Search in sources :

Example 31 with JavaClass

use of org.apache.bcel.classfile.JavaClass in project fb-contrib by mebigfatguy.

the class SuspiciousWaitOnConcurrentObject method visitClassContext.

/**
 * implements the visitor to check for class file version 1.5 or better
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        int major = cls.getMajor();
        if (major >= Const.MAJOR_1_5) {
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        }
    } finally {
        stack = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 32 with JavaClass

use of org.apache.bcel.classfile.JavaClass in project fb-contrib by mebigfatguy.

the class UnboundMethodTemplateParameter method visitClassContext.

/**
 * implements the visitor to accept the class for visiting
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass cls = classContext.getJavaClass();
    cls.accept(this);
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass)

Example 33 with JavaClass

use of org.apache.bcel.classfile.JavaClass in project fb-contrib by mebigfatguy.

the class UnitTestAssertionOddities method visitClassContext.

/**
 * override the visitor to see if this class could be a test class
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        className = cls.getClassName().replace('.', '/');
        isTestCaseDerived = (testCaseClass != null) && cls.instanceOf(testCaseClass);
        isAnnotationCapable = (cls.getMajor() >= 5) && ((testAnnotationClass != null) || (testNGAnnotationClass != null));
        if (isTestCaseDerived || isAnnotationCapable) {
            stack = new OpcodeStack();
            fieldsWithAnnotations = new HashSet<>();
            super.visitClassContext(classContext);
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        stack = null;
        fieldsWithAnnotations = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 34 with JavaClass

use of org.apache.bcel.classfile.JavaClass in project fb-contrib by mebigfatguy.

the class Unjitable method visitClassContext.

/**
 * implements the visitor to accept the class for visiting
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass cls = classContext.getJavaClass();
    cls.accept(this);
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass)

Example 35 with JavaClass

use of org.apache.bcel.classfile.JavaClass in project fb-contrib by mebigfatguy.

the class UseVarArgs method isInherited.

/**
 * looks to see if this method is derived from a super class. If it is we don't want to report on it, as that would entail changing a whole hierarchy
 *
 * @param m
 *            the current method
 * @return if the method is inherited
 *
 * @throws ClassNotFoundException
 *             if the super class(s) aren't found
 */
private boolean isInherited(Method m) throws ClassNotFoundException {
    JavaClass[] infs = javaClass.getAllInterfaces();
    for (JavaClass inf : infs) {
        if (hasMethod(inf, m)) {
            return true;
        }
    }
    JavaClass[] sups = javaClass.getSuperClasses();
    for (JavaClass sup : sups) {
        if (hasMethod(sup, m)) {
            return true;
        }
    }
    return false;
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass)

Aggregations

JavaClass (org.apache.bcel.classfile.JavaClass)144 OpcodeStack (edu.umd.cs.findbugs.OpcodeStack)45 BugInstance (edu.umd.cs.findbugs.BugInstance)43 Method (org.apache.bcel.classfile.Method)28 ToString (com.mebigfatguy.fbcontrib.utils.ToString)27 Field (org.apache.bcel.classfile.Field)17 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)11 ClassParser (org.apache.bcel.classfile.ClassParser)10 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)8 ExceptionTable (org.apache.bcel.classfile.ExceptionTable)8 XField (edu.umd.cs.findbugs.ba.XField)7 Nullable (javax.annotation.Nullable)7 AnnotationEntry (org.apache.bcel.classfile.AnnotationEntry)7 Type (org.apache.bcel.generic.Type)7 Iterator (java.util.Iterator)6 List (java.util.List)6 Map (java.util.Map)6 Set (java.util.Set)6