Search in sources :

Example 61 with OpcodeStack

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

the class NeedlessMemberCollectionSynchronization method visitClassContext.

/**
 * implements the visitor to clear the collectionFields and stack and to report collections that remain unmodified out of clinit or init
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        if ((collectionClass != null) && (mapClass != null)) {
            collectionFields = new HashMap<>();
            aliases = new HashMap<>();
            stack = new OpcodeStack();
            JavaClass cls = classContext.getJavaClass();
            className = cls.getClassName();
            super.visitClassContext(classContext);
            for (FieldInfo fi : collectionFields.values()) {
                if (fi.isSynchronized()) {
                    bugReporter.reportBug(new BugInstance(this, BugType.NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION.name(), NORMAL_PRIORITY).addClass(this).addField(fi.getFieldAnnotation()));
                }
            }
        }
    } finally {
        collectionFields = null;
        aliases = null;
        stack = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) JavaClass(org.apache.bcel.classfile.JavaClass) BugInstance(edu.umd.cs.findbugs.BugInstance)

Example 62 with OpcodeStack

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

the class NonOwnedSynchronization method visitClassContext.

/**
 * implements the visitor to set and clear the stack and priorities
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        stack = new OpcodeStack();
        regPriorities = new HashMap<>();
        super.visitClassContext(classContext);
    } finally {
        stack = null;
        regPriorities = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 63 with OpcodeStack

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

the class NonProductiveMethodCall method visitClassContext.

/**
 * implements the visitor to set and clear the stack
 */
@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 64 with OpcodeStack

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

the class UnnecessaryStoreBeforeReturn method visitClassContext.

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

Example 65 with OpcodeStack

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

the class UnrelatedReturnValues method visitClassContext.

/**
 * implements the visitor to create and destroy the stack and return types
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        currentClass = classContext.getJavaClass();
        stack = new OpcodeStack();
        returnTypes = new HashMap<>();
        super.visitClassContext(classContext);
    } finally {
        currentClass = null;
        stack = null;
        returnTypes = 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