Search in sources :

Example 16 with LocalVariable

use of org.apache.bcel.classfile.LocalVariable in project fb-contrib by mebigfatguy.

the class ImmatureClass method isIDEGeneratedMethodWithCode.

private boolean isIDEGeneratedMethodWithCode(Method m) {
    if (!m.isPublic()) {
        return false;
    }
    String name = m.getName();
    if (Values.CONSTRUCTOR.equals(name) || Values.STATIC_INITIALIZER.equals(name)) {
        return false;
    }
    LocalVariableTable lvt = m.getLocalVariableTable();
    if (lvt == null) {
        return false;
    }
    if (m.getCode().getCode().length <= MAX_EMPTY_METHOD_SIZE) {
        return false;
    }
    int numArgs = m.getArgumentTypes().length;
    if (numArgs == 0) {
        return false;
    }
    int offset = m.isStatic() ? 0 : 1;
    for (int i = 0; i < numArgs; i++) {
        LocalVariable lv = lvt.getLocalVariable(offset + i, 0);
        if ((lv == null) || (lv.getName() == null)) {
            return false;
        }
        Matcher ma = ARG_PATTERN.matcher(lv.getName());
        if (!ma.matches()) {
            return false;
        }
    }
    return true;
}
Also used : LocalVariableTable(org.apache.bcel.classfile.LocalVariableTable) Matcher(java.util.regex.Matcher) LocalVariable(org.apache.bcel.classfile.LocalVariable)

Aggregations

LocalVariable (org.apache.bcel.classfile.LocalVariable)16 LocalVariableTable (org.apache.bcel.classfile.LocalVariableTable)12 BugInstance (edu.umd.cs.findbugs.BugInstance)5 ToString (com.mebigfatguy.fbcontrib.utils.ToString)3 ArrayList (java.util.ArrayList)3 Attribute (org.apache.bcel.classfile.Attribute)2 Code (org.apache.bcel.classfile.Code)2 Constant (org.apache.bcel.classfile.Constant)2 ConstantPool (org.apache.bcel.classfile.ConstantPool)2 ConstantString (org.apache.bcel.classfile.ConstantString)2 ExceptionTable (org.apache.bcel.classfile.ExceptionTable)2 BugType (com.mebigfatguy.fbcontrib.utils.BugType)1 StopOpcodeParsingException (com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException)1 FieldAnnotation (edu.umd.cs.findbugs.FieldAnnotation)1 OpcodeStack (edu.umd.cs.findbugs.OpcodeStack)1 Item (edu.umd.cs.findbugs.OpcodeStack.Item)1 BitSet (java.util.BitSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1