Search in sources :

Example 46 with OpcodeStack

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

the class ModifyingUnmodifiableCollection method visitClassContext.

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

Example 47 with OpcodeStack

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

the class Section508Compliance method visitClassContext.

/**
 * implements the visitor to create and clear the stack
 *
 * @param classContext
 *            the context object of the currently visited class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        if ((jcomponentClass != null) && (accessibleClass != null)) {
            JavaClass cls = classContext.getJavaClass();
            if (cls.instanceOf(jcomponentClass) && !cls.implementationOf(accessibleClass)) {
                bugReporter.reportBug(new BugInstance(this, BugType.S508C_NON_ACCESSIBLE_JCOMPONENT.name(), NORMAL_PRIORITY).addClass(cls));
            }
        }
        stack = new OpcodeStack();
        fieldLabels = new HashSet<>();
        localLabels = new HashMap<>();
        super.visitClassContext(classContext);
        for (XField fa : fieldLabels) {
            bugReporter.reportBug(new BugInstance(this, BugType.S508C_NO_SETLABELFOR.name(), NORMAL_PRIORITY).addClass(this).addField(fa));
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        stack = null;
        fieldLabels = null;
        localLabels = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) XField(edu.umd.cs.findbugs.ba.XField) BugInstance(edu.umd.cs.findbugs.BugInstance)

Example 48 with OpcodeStack

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

the class NonSymmetricEquals method visitClassContext.

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

Example 49 with OpcodeStack

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

the class OptionalIssues method visitClassContext.

/**
 * implements the visitor to filter out pre-1.8 classes, for 1.8+ classes, it creates the opcode stack and active stack ops
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    currentClass = classContext.getJavaClass();
    if (currentClass.getMajor() >= Const.MAJOR_1_8) {
        try {
            stack = new OpcodeStack();
            activeStackOps = new ArrayDeque<>();
            super.visitClassContext(classContext);
        } finally {
            activeStackOps = null;
            stack = null;
        }
    }
    currentClass = null;
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 50 with OpcodeStack

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

the class OrphanedDOMNode method visitClassContext.

/**
 * implements the visitor to create and clear the stack, node creations and store maps
 *
 * @param classContext
 *            the context object for the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        nodeCreations = new HashMap<>();
        nodeStores = new HashMap<>();
        super.visitClassContext(classContext);
    } finally {
        stack = null;
        nodeCreations = null;
        nodeStores = 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