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


Java Code.getLineNumberTable方法代码示例

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


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

示例1: getSourceAnnotationForClass

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
/**
 * @param className
 * @return
 */
static SourceLineAnnotation getSourceAnnotationForClass(String className, String sourceFileName) {

    int lastLine = -1;
    int firstLine = Integer.MAX_VALUE;

    try {
        JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className);
        for (Method m : targetClass.getMethods()) {
            Code c = m.getCode();
            if (c != null) {
                LineNumberTable table = c.getLineNumberTable();
                if (table != null)
                    for (LineNumber line : table.getLineNumberTable()) {
                        lastLine = Math.max(lastLine, line.getLineNumber());
                        firstLine = Math.min(firstLine, line.getLineNumber());
                    }
            }
        }
    } catch (ClassNotFoundException e) {
        AnalysisContext.reportMissingClass(e);
    }
    if (firstLine < Integer.MAX_VALUE)
        return new SourceLineAnnotation(className, sourceFileName, firstLine, lastLine, -1, -1);
    return SourceLineAnnotation.createUnknown(className, sourceFileName);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:SourceLineAnnotation.java

示例2: getLineNumberTable

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
private static LineNumberTable getLineNumberTable(PreorderVisitor visitor) {
	Code code = visitor.getMethod().getCode();
	if (code == null)
		return null;
	return code.getLineNumberTable();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:7,代码来源:SourceLineAnnotation.java

示例3: visitCode

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public void visitCode(Code c) {
	LineNumberTable table = c.getLineNumberTable();
	// LocalVariableTable table = c.getLocalVariableTable();
	if (table == null)
		throw new BuildException(getNoDebugMsg(design.getCurrentClass()), location);
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:7,代码来源:VisitorImpl.java

示例4: getSizeOfSurroundingTryBlock

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public static int getSizeOfSurroundingTryBlock(ConstantPool constantPool, Code code,
        @CheckForNull String vmNameOfExceptionClass, int pc) {
    int size = Integer.MAX_VALUE;
    int tightStartPC = 0;
    int tightEndPC = Integer.MAX_VALUE;
    if (code.getExceptionTable() == null)
        return size;
    for (CodeException catchBlock : code.getExceptionTable()) {
        if (vmNameOfExceptionClass != null) {
            Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
            if (catchType == null || catchType instanceof ConstantClass
                    && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass))
                continue;
        }
        int startPC = catchBlock.getStartPC();
        int endPC = catchBlock.getEndPC();
        if (pc >= startPC && pc <= endPC) {
            int thisSize = endPC - startPC;
            if (size > thisSize) {
                size = thisSize;
                tightStartPC = startPC;
                tightEndPC = endPC;
            }
        }
    }
    if (size == Integer.MAX_VALUE)
        return size;

    // try to guestimate number of lines that correspond
    size = (size + 7) / 8;
    LineNumberTable lineNumberTable = code.getLineNumberTable();
    if (lineNumberTable == null)
        return size;

    int count = 0;
    for (LineNumber line : lineNumberTable.getLineNumberTable()) {
        if (line.getStartPC() > tightEndPC)
            break;
        if (line.getStartPC() >= tightStartPC)
            count++;
    }
    return count;

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

示例5: getLineNumberTable

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
private static LineNumberTable getLineNumberTable(PreorderVisitor visitor) {
    Code code = visitor.getMethod().getCode();
    if (code == null)
        return null;
    return code.getLineNumberTable();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:7,代码来源:SourceLineAnnotation.java

示例6: visit

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
@Override
public void visit(Code obj) {
    lastRegStore = -1;
    lineNumbers = obj.getLineNumberTable();
    super.visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:7,代码来源:FindBadForLoop.java

示例7: getSizeOfSurroundingTryBlock

import org.apache.bcel.classfile.Code; //导入方法依赖的package包/类
public static int getSizeOfSurroundingTryBlock(ConstantPool constantPool, Code code,
        @CheckForNull @SlashedClassName String vmNameOfExceptionClass, int pc) {
    int size = Integer.MAX_VALUE;
    int tightStartPC = 0;
    int tightEndPC = Integer.MAX_VALUE;
    if (code.getExceptionTable() == null)
        return size;
    for (CodeException catchBlock : code.getExceptionTable()) {
        if (vmNameOfExceptionClass != null) {
            Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
            if (catchType == null) continue;
            if (catchType instanceof ConstantClass) {
                String name = ((ConstantClass) catchType).getBytes(constantPool);
                   if (!name.equals(vmNameOfExceptionClass))
                       continue;
            }
        }
        int startPC = catchBlock.getStartPC();
        int endPC = catchBlock.getEndPC();
        if (pc >= startPC && pc <= endPC) {
            int thisSize = endPC - startPC;
            if (size > thisSize) {
                size = thisSize;
                tightStartPC = startPC;
                tightEndPC = endPC;
            }
        }
    }
    if (size == Integer.MAX_VALUE)
        return size;

    // try to guestimate number of lines that correspond
    size = (size + 7) / 8;
    LineNumberTable lineNumberTable = code.getLineNumberTable();
    if (lineNumberTable == null)
        return size;

    int count = 0;
    for (LineNumber line : lineNumberTable.getLineNumberTable()) {
        if (line.getStartPC() > tightEndPC)
            break;
        if (line.getStartPC() >= tightStartPC)
            count++;
    }
    return count;

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:48,代码来源:Util.java


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