Search in sources :

Example 21 with OpcodeStack

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

the class UseTryWithResources method visitClassContext.

@Override
public void visitClassContext(ClassContext classContext) {
    if (autoCloseableClass == null) {
        return;
    }
    try {
        int majorVersion = classContext.getJavaClass().getMajor();
        if (majorVersion >= Const.MAJOR_1_7) {
            stack = new OpcodeStack();
            finallyBlocks = new HashMap<>();
            regStoredPCs = new HashMap<>();
            super.visitClassContext(classContext);
        }
    } finally {
        stack = null;
        finallyBlocks = null;
        regStoredPCs = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 22 with OpcodeStack

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

the class CollectMethodsReturningImmutableCollections method visitClassContext.

@Override
public void visitClassContext(ClassContext context) {
    try {
        stack = new OpcodeStack();
        clsName = context.getJavaClass().getClassName();
        super.visitClassContext(context);
    } finally {
        stack = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 23 with OpcodeStack

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

the class OverlyPermissiveMethod method visitClassContext.

@Override
public void visitClassContext(ClassContext classContext) {
    try {
        cls = classContext.getJavaClass();
        ClassDescriptor cd = classContext.getClassDescriptor();
        callingClass = cd.getClassName();
        callingPackage = cd.getPackageName();
        stack = new OpcodeStack();
        super.visitClassContext(classContext);
    } finally {
        callingPackage = null;
        stack = null;
    }
}
Also used : ClassDescriptor(edu.umd.cs.findbugs.classfile.ClassDescriptor) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 24 with OpcodeStack

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

the class ParallelLists method visitClassContext.

@Override
public void visitClassContext(final ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        listFields = new HashSet<>();
        Field[] flds = cls.getFields();
        for (Field f : flds) {
            String sig = f.getSignature();
            if (sig.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
                sig = SignatureUtils.trimSignature(sig);
                if (sig.startsWith("java/util/") && sig.endsWith("List")) {
                    listFields.add(f.getName());
                }
            } else if (sig.startsWith(Values.SIG_ARRAY_PREFIX) && !sig.startsWith(Values.SIG_ARRAY_OF_ARRAYS_PREFIX)) {
                listFields.add(f.getName());
            }
        }
        if (!listFields.isEmpty()) {
            stack = new OpcodeStack();
            indexToFieldMap = new HashMap<>();
            super.visitClassContext(classContext);
        }
    } finally {
        stack = null;
        indexToFieldMap = null;
    }
}
Also used : Field(org.apache.bcel.classfile.Field) XField(edu.umd.cs.findbugs.ba.XField) JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 25 with OpcodeStack

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

the class PartiallyConstructedObjectAccess method visitClassContext.

/**
 * implements the visitor to set up the stack and methodToCalledmethods map reports calls to public non final methods from methods called from constructors.
 *
 * @param classContext
 *            the context object of the currently parsed class
 */
@Override
public void visitClassContext(final ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        if (!cls.isFinal()) {
            stack = new OpcodeStack();
            methodToCalledMethods = new HashMap<>();
            super.visitClassContext(classContext);
            if (!methodToCalledMethods.isEmpty()) {
                reportChainedMethods();
            }
        }
    } finally {
        stack = null;
        methodToCalledMethods = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) 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