本文整理汇总了Java中org.apache.bcel.classfile.LocalVariable.getStartPC方法的典型用法代码示例。如果您正苦于以下问题:Java LocalVariable.getStartPC方法的具体用法?Java LocalVariable.getStartPC怎么用?Java LocalVariable.getStartPC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.LocalVariable
的用法示例。
在下文中一共展示了LocalVariable.getStartPC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: visit
import org.apache.bcel.classfile.LocalVariable; //导入方法依赖的package包/类
@Override
public void visit(LocalVariable obj) {
if (isReservedName(obj.getName())) {
LocalVariableAnnotation var = new LocalVariableAnnotation(obj.getName(), obj.getIndex(), obj.getStartPC());
SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, obj.getStartPC());
BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER", NORMAL_PRIORITY)
.addClassAndMethod(this).add(var).add(source);
bugReporter.reportBug(bug);
}
}