Search in sources :

Example 91 with OpcodeStack

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

the class CloneUsability method visitClassContext.

/**
 * overrides the visitor to check for classes that implement Cloneable.
 *
 * @param classContext
 *            the context object that holds the JavaClass being parsed
 */
@Override
public void visitClassContext(ClassContext classContext) {
    if (cloneClass == null) {
        return;
    }
    try {
        cls = classContext.getJavaClass();
        if (cls.implementationOf(cloneClass)) {
            clsName = cls.getClassName();
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    } finally {
        cls = null;
        stack = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 92 with OpcodeStack

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

the class FunctionalInterfaceIssues method visitClassContext.

@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        if (cls.getMajor() >= Const.MAJOR_1_8) {
            bootstrapAtt = getBootstrapAttribute(cls);
            if (bootstrapAtt != null) {
                stack = new OpcodeStack();
                functionalInterfaceInfo = new HashMap<>();
                super.visitClassContext(classContext);
                for (Map.Entry<Method, List<FIInfo>> entry : functionalInterfaceInfo.entrySet()) {
                    for (FIInfo fii : entry.getValue()) {
                    }
                }
            }
        }
    } finally {
        functionalInterfaceInfo = null;
        bootstrapAtt = null;
        stack = null;
    }
}
Also used : JavaClass(org.apache.bcel.classfile.JavaClass) OpcodeStack(edu.umd.cs.findbugs.OpcodeStack) ArrayList(java.util.ArrayList) List(java.util.List) Method(org.apache.bcel.classfile.Method) HashMap(java.util.HashMap) Map(java.util.Map)

Example 93 with OpcodeStack

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

the class LocalHangingExecutor method visitClassContext.

/**
 * finds ExecutorService objects that don't get a call to the terminating methods, and thus, never appear to be shutdown properly (the threads exist until
 * shutdown is called)
 *
 * @param classContext
 *            the class context object of the currently parsed java class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    localHEDetector.visitClassContext(classContext);
    try {
        hangingFieldCandidates = new HashMap<>();
        exemptExecutors = new HashMap<>();
        parseFieldsForHangingCandidates(classContext);
        if (!hangingFieldCandidates.isEmpty()) {
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
            reportHangingExecutorFieldBugs();
        }
    } finally {
        stack = null;
        hangingFieldCandidates = null;
        exemptExecutors = null;
    }
}
Also used : OpcodeStack(edu.umd.cs.findbugs.OpcodeStack)

Example 94 with OpcodeStack

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

the class IOIssues method visitClassContext.

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

Example 95 with OpcodeStack

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

the class CollectStatistics method visitClassContext.

/**
 * implements the visitor to collect statistics on this class
 *
 * @param classContext
 *            the currently class
 */
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        AnnotationEntry[] annotations = cls.getAnnotationEntries();
        classHasAnnotation = !CollectionUtils.isEmpty(annotations);
        stack = new OpcodeStack();
        selfCallTree = new HashMap<>();
        super.visitClassContext(classContext);
        performModifyStateClosure(classContext.getJavaClass());
    } finally {
        stack = null;
        selfCallTree = null;
        curMethod = null;
    }
}
Also used : AnnotationEntry(org.apache.bcel.classfile.AnnotationEntry) 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