当前位置: 首页>>代码示例>>Java>>正文


Java LocalVariable类代码示例

本文整理汇总了Java中org.apache.bcel.classfile.LocalVariable的典型用法代码示例。如果您正苦于以下问题:Java LocalVariable类的具体用法?Java LocalVariable怎么用?Java LocalVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalVariable类属于org.apache.bcel.classfile包,在下文中一共展示了LocalVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkReferences

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
private void checkReferences()
{
   if (mLocalVariableTable != null) {
      for (int i = 0; i < mLocalVariableTable.getLength(); i++) {
           if (!mLocalVariableBitSet.get(i)) {
               final LocalVariable localVariable =
                   mLocalVariableTable.getLocalVariable(i);
               if (localVariable != null
                   && !localVariable.getName().equals("this"))
               {
                   log(0,
                       "unread.variable",
                       new Object[] {
                           mCurrentJavaClass.getClassName(),
                           mCurrentMethod.getName(),
                           localVariable.getName(),});
               }
           }
       }
   }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:UnreadVariableCheck.java

示例2: getAllLocalDecls

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
static String[] getAllLocalDecls(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
Vector<String> v = new Vector<String>();

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    String e = tp.toString() + " "
	    + generatedLocalName(tp, l.getName()) + ";";
    if (!v.contains(e)) {
	v.addElement(e);
    }
}

String[] result = new String[v.size()];
result = v.toArray(result);
// for (int i = 0; i < v.size(); i++) {
// result[i] = (String) v.elementAt(i);
// System.out.println("localdecls for " + m + ": " + result[i]);
// }

return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:24,代码来源:MethodTable.java

示例3: getLocalVariable

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
@CheckForNull
GenericObjectType getLocalVariable(int index, int pos) {
    if (genericLocalVariables == null || !genericLocalVariables.get(index))
        return null;
    for (LocalVariable local : localTypeTable.getLocalVariableTypeTable())
        if (local.getIndex() == index && local.getStartPC() <= pos
                && pos < +local.getStartPC() + local.getLength()) {
            String signature = local.getSignature();
            if (signature.indexOf('<') < 0) continue;
            Type t;
            try {
                t = GenericUtilities.getType(signature);
                if (t instanceof GenericObjectType)
                    return (GenericObjectType) t;
            } catch (RuntimeException e) {
                AnalysisContext.logError("Bad signature " + signature
                        + " for " + local.getName(), e);

            }
            return null;
        }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:TypeFrameModelingVisitor.java

示例4: getLocalVariableAtPC

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
/**
 * returns the local variable at an index int the scope of PC
 *
 * @param index the variable index
 * @param PC the PC where the variable is used
 */
public static LocalVariable getLocalVariableAtPC(LocalVariableTable lvt, int index, int pc) {
	int length = lvt.getTableLength();
	LocalVariable[] lvs = lvt.getLocalVariableTable();
	
	for(int i = 0; i < length; i++) {
		if (lvs[i].getIndex() == index) {
			int startPC = lvs[i].getStartPC();
			if ((pc >= startPC) && (pc < (startPC + lvs[i].getLength())))
				return lvs[i];
		}
	}
	
	return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:LVTHelper.java

示例5: pushByLocalObjectLoad

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
private void pushByLocalObjectLoad(DismantleBytecode dbc, int register) {
Method m = dbc.getMethod();
LocalVariableTable lvt = m.getLocalVariableTable();
if (lvt != null) {
	LocalVariable lv = LVTHelper.getLocalVariableAtPC(lvt, register, dbc.getPC());
	if (lv != null) {
		String signature = lv.getSignature();
		pushByLocalLoad(signature, register);
		return;
	}
}
pushBySignature("");
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:OpcodeStack.java

示例6: getParamName

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
static String getParamName(Method m, int paramNr) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();

int minPos = Integer.MAX_VALUE;
String res = null;

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    if (l.getIndex() == paramNr) {
	int startPos = l.getStartPC();

	if (startPos < minPos) {
	    minPos = startPos;
	    res = l.getName();
	}
    }
}

if (res != null) {
    return res;
}

System.err.println("getParamName: could not find name of param "
	+ paramNr);
System.exit(1);

return null;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:29,代码来源:MethodTable.java

示例7: getAllLocalTypes

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
static Type[] getAllLocalTypes(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
Type[] result = new Type[lt.length];

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    result[i] = tp;
}

return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:13,代码来源:MethodTable.java

示例8: getAllLocalNames

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
static String[] getAllLocalNames(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
String[] result = new String[lt.length];

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    String e = generatedLocalName(tp, l.getName());
    result[i] = e;
}
return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:13,代码来源:MethodTable.java

示例9: visitLocalVariable

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
@Override
public void visitLocalVariable(LocalVariable obj) {
	String name1 = obj.getSignature();
	if (this.parser.isDebug()) {
		this.parser.debug("visitLocalVariable: obj.getSignature() = " + name1);
		Collection<String> types = ParseUtil.signatureToTypes(name1);
		for (String name : types) {
			this.jClass.getDetail().addVariableType(name);
			if (this.parser.isDebug()) {
				this.parser.debug("visitLocalVariable: variable type = " + name);
			}
		}
	}
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:15,代码来源:SmallClassFileVisitor.java

示例10: visitLocalVariableTable

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
@Override
public void visitLocalVariableTable(LocalVariableTable obj) {
    super.visitLocalVariableTable(obj);
    LocalVariable[] local_variable_table = obj.getLocalVariableTable();
    for (LocalVariable aLocal_variable_table : local_variable_table)
        aLocal_variable_table.accept(this);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:PreorderVisitor.java

示例11: getLocalVariableAtPC

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
/**
 * returns the local variable at an index int the scope of PC
 * 
 * @param lvt
 *            the local variable table
 * @param index
 *            the variable index
 * @param pc
 *            the PC where the variable is used
 */
public static LocalVariable getLocalVariableAtPC(@Nonnull LocalVariableTable lvt, int index, int pc) {
    int length = lvt.getTableLength();
    LocalVariable[] lvs = lvt.getLocalVariableTable();

    for (int i = 0; i < length; i++) {
        if (lvs[i].getIndex() == index) {
            int startPC = lvs[i].getStartPC();
            if ((pc >= startPC) && (pc < (startPC + lvs[i].getLength())))
                return lvs[i];
        }
    }

    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:LVTHelper.java

示例12: getLocalVariableAnnotation

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
public static LocalVariableAnnotation getLocalVariableAnnotation(Method method, int local, int position1, int position2) {

        LocalVariableTable localVariableTable = method.getLocalVariableTable();
        String localName = "?";
        if (localVariableTable != null) {
            LocalVariable lv1 = localVariableTable.getLocalVariable(local, position1);
            if (lv1 == null) {
                lv1 = localVariableTable.getLocalVariable(local, position2);
                position1 = position2;
            }
            if (lv1 != null)
                localName = lv1.getName();
            else
                for (LocalVariable lv : localVariableTable.getLocalVariableTable()) {
                    if (lv.getIndex() == local) {
                        if (!localName.equals("?") && !localName.equals(lv.getName())) {
                            // not a single consistent name
                            localName = "?";
                            break;
                        }
                        localName = lv.getName();
                    }
                }
        }
        LineNumberTable lineNumbers = method.getLineNumberTable();
        if (lineNumbers == null)
            return new LocalVariableAnnotation(localName, local, position1);
        int line = lineNumbers.getSourceLine(position1);
        return new LocalVariableAnnotation(localName, local, position1, line);
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:LocalVariableAnnotation.java

示例13: checkLocalVariableName

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
/**
 * Get the name of given local variable (if possible) and store it in the
 * HeuristicPropertySet.
 * 
 * @param lvt
 *            the LocalVariableTable
 * @param local
 *            index of the local
 * @param pc
 *            program counter value of the instruction
 */
private void checkLocalVariableName(LocalVariableTable lvt, int local, int pc,
        WarningPropertySet<DeadLocalStoreProperty> propertySet) {
    if (lvt != null) {
        LocalVariable lv = lvt.getLocalVariable(local, pc);
        if (lv != null) {
            String localName = lv.getName();
            propertySet.setProperty(DeadLocalStoreProperty.LOCAL_NAME, localName);
        }
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:23,代码来源:FindDeadLocalStores.java

示例14: visit

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
@Override
public void visit(Code obj) {

    if (!getMethod().isPublic() && !getMethod().isProtected())
        return;
    SignatureParser p = new SignatureParser(getMethodSig());
    LocalVariableTable t = obj.getLocalVariableTable();

    if (t == null)
        return;
    ParameterProperty property = new ParameterProperty();

    int index = getMethod().isStatic() ? 0 : 1;
    int parameterNumber = 0;
    for (Iterator<String> i = p.parameterSignatureIterator(); i.hasNext();) {
        String s = i.next();
        LocalVariable localVariable = t.getLocalVariable(index, 0);
        if (localVariable != null) {
            String name = localVariable.getName();
            if (s.equals("J") && (name.toLowerCase().indexOf("instant") >= 0 || name.startsWith("date"))) {

                // System.out.println(getFullyQualifiedMethodName() + " " + s + " " + index + " " + name);
                property.setParamWithProperty(parameterNumber, true);
            }
        }
        if (s.equals("J") || s.equals("D"))
            index += 2;
        else
            index += 1;
        parameterNumber++;
    }
    if (!property.isEmpty()) {
        // System.out.println(getFullyQualifiedMethodName() + " " + property);
        database.setProperty(getMethodDescriptor(), property);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:37,代码来源:TrainLongInstantfParams.java

示例15: visit

import org.apache.bcel.classfile.LocalVariable; //导入依赖的package包/类
@Override
public void visit(LocalVariableTable obj) {
    if (ENABLE_LOCALS) {
        if (staticMethod)
            return;

        LocalVariable[] vars = obj.getLocalVariableTable();
        // System.out.println("Num params = " + numParms);
        for (LocalVariable var : vars) {
            if (var.getIndex() < numParms)
                continue;
            String varName = var.getName();
            if (varName.equals("serialVersionUID"))
                continue;
            Field f = classFields.get(varName);
            // System.out.println("Checking " + varName);
            // System.out.println(" got " + f);
            // TODO: we could distinguish between obscuring a field in the
            // same class
            // vs. obscuring a field in a superclass. Not sure how important
            // that is.
            if (f != null) {
                FieldAnnotation fa = FieldAnnotation.fromBCELField(getDottedClassName(), f);
                if (true || var.getStartPC() > 0)
                    bugReporter.reportBug(new BugInstance(this, "MF_METHOD_MASKS_FIELD", LOW_PRIORITY)
                            .addClassAndMethod(this).addField(fa).addSourceLine(this, var.getStartPC() - 1));
            }
        }
    }
    super.visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:FindMaskedFields.java


注:本文中的org.apache.bcel.classfile.LocalVariable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。