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


Java CodeException.getCatchType方法代码示例

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


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

示例1: visit

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
@Override
public void visit(CodeException obj) {
    int type = obj.getCatchType();
    if (type == 0)
        return;
    String name = getConstantPool().constantToString(getConstantPool().getConstant(type));
    if (DEBUG) {
        String msg = "Catching " + name + " in " + getFullyQualifiedMethodName();
        if (msgs.add(msg))
            System.out.println(msg);
    }
    if (name.equals("java.lang.IllegalMonitorStateException"))
        bugReporter.reportBug(new BugInstance(this, "IMSE_DONT_CATCH_IMSE", HIGH_PRIORITY).addClassAndMethod(this)
                .addSourceLine(this.classContext, this, obj.getHandlerPC()));

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

示例2: uniqueLocations

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
/**
 * @param derefLocationSet
 * @return
 */
private boolean uniqueLocations(Collection<Location> derefLocationSet) {
    boolean uniqueDereferenceLocations = false;
    CodeException[] exceptionTable = method.getCode().getExceptionTable();
    if (exceptionTable == null)
        return true;
    checkForCatchAll: {
        for (CodeException e : exceptionTable)
            if (e.getCatchType() == 0)
                break checkForCatchAll;
        return true;
    }

    LineNumberTable table = method.getLineNumberTable();
    if (table == null)
        uniqueDereferenceLocations = true;
    else {
        BitSet linesMentionedMultipleTimes = classContext.linesMentionedMultipleTimes(method);
        for (Location loc : derefLocationSet) {
            int lineNumber = table.getSourceLine(loc.getHandle().getPosition());
            if (lineNumber > 0 && !linesMentionedMultipleTimes.get(lineNumber))
                uniqueDereferenceLocations = true;
        }
    }
    return uniqueDereferenceLocations;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:FindNullDeref.java

示例3: visit

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
public void visit(CodeException obj) {
	int type = obj.getCatchType();
	if (type == 0) return;
	String name = getConstantPool().constantToString(getConstantPool().getConstant(type));
	if (DEBUG) {
		String msg = "Catching " + name + " in " + getFullyQualifiedMethodName();
		if (msgs.add(msg))
			System.out.println(msg);
	}
	if (name.equals("java.lang.IllegalMonitorStateException"))
		bugReporter.reportBug(new BugInstance(this, "IMSE_DONT_CATCH_IMSE", HIGH_PRIORITY)
		        .addClassAndMethod(this)
		        .addSourceLine(this, obj.getHandlerPC()));

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:DontCatchIllegalMonitorStateException.java

示例4: visitCodeException

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
public void visitCodeException(CodeException c) {
	c.toString(pool, false);

	int catch_type = c.getCatchType();

	if (catch_type == 0)
		return;

	String temp = pool.getConstantString(catch_type, Constants.CONSTANT_Class);
	String str = Utility.compactClassName(temp, false);

	log("         catch=" + str, Project.MSG_DEBUG);
	design.checkClass(str);
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:15,代码来源:VisitorImpl.java

示例5: getExceptionSig

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
public static String getExceptionSig(DismantleBytecode dbc, CodeException e) {
    if (e.getCatchType() == 0)
        return "Ljava/lang/Throwable;";
    Constant c = dbc.getConstantPool().getConstant(e.getCatchType());
    if (c instanceof ConstantClass)
        return "L" + ((ConstantClass) c).getBytes(dbc.getConstantPool()) + ";";
    return "Ljava/lang/Throwable;";
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:OpcodeStack.java

示例6: flush

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
/**
 * Flush out cached state at the end of a method.
 */
private void flush() {
    
    if (pendingAbsoluteValueBug != null) {
        absoluteValueAccumulator.accumulateBug(pendingAbsoluteValueBug, pendingAbsoluteValueBugSourceLine);
        pendingAbsoluteValueBug = null;
        pendingAbsoluteValueBugSourceLine = null;
    }
    accumulator.reportAccumulatedBugs();
    if (sawLoadOfMinValue)
        absoluteValueAccumulator.clearBugs();
    else
        absoluteValueAccumulator.reportAccumulatedBugs();
    if (gcInvocationBugReport != null && !sawCurrentTimeMillis) {
        // Make sure the GC invocation is not in an exception handler
        // for OutOfMemoryError.
        boolean outOfMemoryHandler = false;
        for (CodeException handler : exceptionTable) {
            if (gcInvocationPC < handler.getHandlerPC() || gcInvocationPC > handler.getHandlerPC() + OOM_CATCH_LEN) {
                continue;
            }
            int catchTypeIndex = handler.getCatchType();
            if (catchTypeIndex > 0) {
                ConstantPool cp = getThisClass().getConstantPool();
                Constant constant = cp.getConstant(catchTypeIndex);
                if (constant instanceof ConstantClass) {
                    String exClassName = (String) ((ConstantClass) constant).getConstantValue(cp);
                    if (exClassName.equals("java/lang/OutOfMemoryError")) {
                        outOfMemoryHandler = true;
                        break;
                    }
                }
            }
        }

        if (!outOfMemoryHandler) {
            bugReporter.reportBug(gcInvocationBugReport);
        }
    }

    sawCurrentTimeMillis = false;
    gcInvocationBugReport = null;

    exceptionTable = null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:48,代码来源:DumbMethods.java

示例7: examineRedundantBranches

import org.apache.bcel.classfile.CodeException; //导入方法依赖的package包/类
/**
 * Examine redundant branches.
 */
private void examineRedundantBranches() {
    for (RedundantBranch redundantBranch : redundantBranchList) {
        if (DEBUG)
            System.out.println("Redundant branch: " + redundantBranch);
        int lineNumber = redundantBranch.lineNumber;

        // The source to bytecode compiler may sometimes duplicate blocks of
        // code along different control paths. So, to report the bug,
        // we check to ensure that the branch is REALLY determined each
        // place it is duplicated, and that it is determined in the same
        // way.

        boolean confused = undeterminedBranchSet.get(lineNumber)
                || (definitelySameBranchSet.get(lineNumber) && definitelyDifferentBranchSet.get(lineNumber));

        // confused if there is JSR confusion or multiple null checks with
        // different results on the same line

        boolean reportIt = true;

        if (lineMentionedMultipleTimes.get(lineNumber) && confused)
            reportIt = false;
        else if (redundantBranch.location.getBasicBlock().isInJSRSubroutine() /*
                                                                               * occurs
                                                                               * in
                                                                               * a
                                                                               * JSR
                                                                               */
                && confused)
            reportIt = false;
        else {
            int pc = redundantBranch.location.getHandle().getPosition();
            for (CodeException e : method.getCode().getExceptionTable()) {
                if (e.getCatchType() == 0 && e.getStartPC() != e.getHandlerPC() && e.getEndPC() <= pc
                        && pc <= e.getEndPC() + 5)
                    reportIt = false;
            }
        }

        if (reportIt) {
            collector.foundRedundantNullCheck(redundantBranch.location, redundantBranch);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:48,代码来源:NullDerefAndRedundantComparisonFinder.java


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