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


Java LineNumberTable.getTableLength方法代码示例

本文整理汇总了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");
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:45,代码来源:LineNumberMap.java

示例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");
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:46,代码来源:LineNumberMap.java


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