Search in sources :

Example 31 with OpcodeStack

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

the class AnnotationIssues method visitClassContext.

@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        if (cls.getMajor() >= Const.MAJOR_1_5) {
            if (isCollecting() || !cls.isAnonymous()) {
                stack = new OpcodeStack();
                assumedNullTill = new HashMap<>();
                assumedNonNullTill = new HashMap<>();
                noAssumptionsPossible = new HashSet<>();
                super.visitClassContext(classContext);
            }
        }
    } finally {
        stack = null;
        assumedNullTill = null;
        assumedNonNullTill = null;
        noAssumptionsPossible = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 32 with OpcodeStack

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

the class ArrayBasedCollections method visitClassContext.

/**
 * implement the visitor to report bugs if no Tree comparators were found
 *
 * @param classContext
 *            the context object for the class currently being parsed
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        mapBugs = new ArrayList<>();
        setBugs = new ArrayList<>();
        hasMapComparator = false;
        hasSetComparator = false;
        super.visitClassContext(classContext);
        if (!hasMapComparator) {
            for (BugInstance bi : mapBugs) {
                bugReporter.reportBug(bi);
            }
        }
        if (!hasSetComparator) {
            for (BugInstance bi : setBugs) {
                bugReporter.reportBug(bi);
            }
        }
    } finally {
        stack = null;
        mapBugs = null;
        setBugs = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) BugInstance(edu.umd.cs.findbugs.BugInstance)

Example 33 with OpcodeStack

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

the class ArrayWrappedCallByReference method visitClassContext.

/**
 * implement the visitor to create and clear the stack and wrappers
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        wrappers = new HashMap<>(10);
        super.visitClassContext(classContext);
    } finally {
        stack = null;
        wrappers = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 34 with OpcodeStack

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

the class BogusExceptionDeclaration method visitClassContext.

/**
 * overrides the visitor to create the opcode stack
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        if ((runtimeExceptionClass != null) && (exceptionClass != null)) {
            stack = new OpcodeStack();
            declaredCheckedExceptions = new HashSet<>(6);
            JavaClass cls = classContext.getJavaClass();
            classIsFinal = cls.isFinal();
            classIsAnonymous = cls.isAnonymous();
            super.visitClassContext(classContext);
        }
    } finally {
        declaredCheckedExceptions = null;
        stack = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) JavaClass(org.apache.bcel.classfile.JavaClass)

Example 35 with OpcodeStack

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

the class BuryingLogic method visitClassContext.

/**
 * implements the visitor to reset the opcode stack, and initialize if tracking collections
 *
 * @param classContext
 *            the currently parsed java class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        ifBlocks = new IfBlocks();
        gotoBranchPCs = new BitSet();
        casePositions = new BitSet();
        super.visitClassContext(classContext);
    } finally {
        stack = null;
        ifBlocks = null;
        catchPCs = null;
        gotoBranchPCs = null;
        casePositions = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) BitSet(java.util.BitSet)

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