Search in sources :

Example 51 with OpcodeStack

use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.

the class OverlyConcreteParameter method visitClassContext.

/**
 * implements the visitor to collect classes that constrains this class (super classes/interfaces) and to reset the opcode stack
 *
 * @param classContext
 *            the currently parse class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        cls = classContext.getJavaClass();
        if (!isaConversionClass(cls)) {
            JavaClass[] infs = cls.getAllInterfaces();
            JavaClass[] sups = cls.getSuperClasses();
            constrainingClasses = new JavaClass[infs.length + sups.length];
            System.arraycopy(infs, 0, constrainingClasses, 0, infs.length);
            System.arraycopy(sups, 0, constrainingClasses, infs.length, sups.length);
            parameterDefiners = new HashMap<>();
            usedParameters = new BitSet();
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        constrainingClasses = null;
        parameterDefiners = null;
        usedParameters = null;
        stack = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) BitSet(java.util.BitSet)

Example 52 with OpcodeStack

use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.

the class SuboptimalExpressionOrder method visitClassContext.

/**
 * overrides the visitor to setup the opcode stack
 *
 * @param clsContext
 *            the context object of the currently parse class
 */
@Override
public void visitClassContext(ClassContext clsContext) {
    try {
        stack = new OpcodeStack();
        super.visitClassContext(clsContext);
    } finally {
        stack = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 53 with OpcodeStack

use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.

the class SuspiciousCloneAlgorithm method visitClassContext.

/**
 * override the visitor to look for classes that implement Cloneable
 *
 * @param classContext
 *            the context object of the class to be checked
 */
@Override
public void visitClassContext(ClassContext classContext) {
    if (cloneableClass == null) {
        return;
    }
    try {
        JavaClass cls = classContext.getJavaClass();
        if (cls.implementationOf(cloneableClass)) {
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        stack = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 54 with OpcodeStack

use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.

the class MethodInfo method visitClassContext.

/**
 * implements the visitor to actually iterate twice over this class, once for compareTo and once for compare.
 *
 * @param classContext
 *            the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        for (CompareSpec entry : compareClasses) {
            if (cls.implementationOf(entry.getCompareClass())) {
                methodInfo = entry.getMethodInfo();
                stack = new OpcodeStack();
                super.visitClassContext(classContext);
                break;
            }
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        methodInfo = null;
        stack = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 55 with OpcodeStack

use of edu.umd.cs.findbugs.OpcodeStack in project fb-contrib by mebigfatguy.

the class PossibleConstantAllocationInLoop method visitClassContext.

@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        allocations = new HashMap<>();
        storedAllocations = new HashMap<>();
        switchInfos = new ArrayList<>();
        super.visitClassContext(classContext);
    } finally {
        stack = null;
        allocations = null;
        storedAllocations = null;
        switchInfos = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Aggregations

OpcodeStack (edu.umd.cs.findbugs.OpcodeStack)95 JavaClass (org.apache.bcel.classfile.JavaClass)20 BitSet (java.util.BitSet)15 BugInstance (edu.umd.cs.findbugs.BugInstance)7 HashMap (java.util.HashMap)4 Map (java.util.Map)3 Field (org.apache.bcel.classfile.Field)3 StopOpcodeParsingException (com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException)2 FieldAnnotation (edu.umd.cs.findbugs.FieldAnnotation)2 XField (edu.umd.cs.findbugs.ba.XField)2 AnnotationEntry (org.apache.bcel.classfile.AnnotationEntry)2 Method (org.apache.bcel.classfile.Method)2 ToString (com.mebigfatguy.fbcontrib.utils.ToString)1 ClassDescriptor (edu.umd.cs.findbugs.classfile.ClassDescriptor)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 ConstantInteger (org.apache.bcel.classfile.ConstantInteger)1