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


Java LocalVariableTable.getLocalVariable方法代码示例

本文整理汇总了Java中org.apache.bcel.classfile.LocalVariableTable.getLocalVariable方法的典型用法代码示例。如果您正苦于以下问题:Java LocalVariableTable.getLocalVariable方法的具体用法?Java LocalVariableTable.getLocalVariable怎么用?Java LocalVariableTable.getLocalVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.classfile.LocalVariableTable的用法示例。


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

示例1: getLocalVariableAnnotation

import org.apache.bcel.classfile.LocalVariableTable; //导入方法依赖的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

示例2: checkLocalVariableName

import org.apache.bcel.classfile.LocalVariableTable; //导入方法依赖的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

示例3: visit

import org.apache.bcel.classfile.LocalVariableTable; //导入方法依赖的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

示例4: checkLocalVariableName

import org.apache.bcel.classfile.LocalVariableTable; //导入方法依赖的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:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:23,代码来源:FindDeadLocalStores.java


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