本文整理汇总了Java中org.apache.bcel.classfile.LineNumberTable.getTableLength方法的典型用法代码示例。如果您正苦于以下问题:Java LineNumberTable.getTableLength方法的具体用法?Java LineNumberTable.getTableLength怎么用?Java LineNumberTable.getTableLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.LineNumberTable
的用法示例。
在下文中一共展示了LineNumberTable.getTableLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.apache.bcel.classfile.LineNumberTable; //导入方法依赖的package包/类
/**
* Build the line number information.
* Should be called before any other methods.
*/
public void build() {
int numGood = 0, numBytecodes = 0;
if (DEBUG) {
System.out.println("Method: " + methodGen.getName() + " - " + methodGen.getSignature() +
"in class " + methodGen.getClassName());
}
// Associate line number information with each InstructionHandle
LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());
if (table != null && table.getTableLength() > 0) {
checkTable(table);
InstructionHandle handle = methodGen.getInstructionList().getStart();
while (handle != null) {
int bytecodeOffset = handle.getPosition();
if (bytecodeOffset < 0)
throw new IllegalStateException("Bad bytecode offset: " + bytecodeOffset);
if (DEBUG) System.out.println("Looking for source line for bytecode offset " + bytecodeOffset);
int sourceLine;
try {
sourceLine = table.getSourceLine(bytecodeOffset);
} catch (ArrayIndexOutOfBoundsException e) {
if (LINE_NUMBER_BUG)
throw e;
else
sourceLine = -1;
}
if (sourceLine >= 0)
++numGood;
lineNumberMap.put(handle,
new LineNumber(bytecodeOffset, sourceLine));
handle = handle.getNext();
++numBytecodes;
}
hasLineNumbers = true;
if (DEBUG) System.out.println("\t" + numGood + "/" + numBytecodes + " had valid line numbers");
}
}
示例2: build
import org.apache.bcel.classfile.LineNumberTable; //导入方法依赖的package包/类
/**
* Build the line number information. Should be called before any other
* methods.
*/
public void build() {
int numGood = 0, numBytecodes = 0;
if (DEBUG) {
System.out.println("Method: " + methodGen.getName() + " - " + methodGen.getSignature() + "in class "
+ methodGen.getClassName());
}
// Associate line number information with each InstructionHandle
LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());
if (table != null && table.getTableLength() > 0) {
checkTable(table);
InstructionHandle handle = methodGen.getInstructionList().getStart();
while (handle != null) {
int bytecodeOffset = handle.getPosition();
if (bytecodeOffset < 0)
throw new IllegalStateException("Bad bytecode offset: " + bytecodeOffset);
if (DEBUG)
System.out.println("Looking for source line for bytecode offset " + bytecodeOffset);
int sourceLine;
try {
sourceLine = table.getSourceLine(bytecodeOffset);
} catch (ArrayIndexOutOfBoundsException e) {
if (LINE_NUMBER_BUG)
throw e;
else
sourceLine = -1;
}
if (sourceLine >= 0)
++numGood;
lineNumberMap.put(handle, new LineNumber(bytecodeOffset, sourceLine));
handle = handle.getNext();
++numBytecodes;
}
hasLineNumbers = true;
if (DEBUG)
System.out.println("\t" + numGood + "/" + numBytecodes + " had valid line numbers");
}
}