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


Java CodeExceptionGen.getCatchType方法代码示例

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


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

示例1: transfer

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
public void transfer(BasicBlock basicBlock, InstructionHandle end, BlockType start, BlockType result)
		throws DataflowAnalysisException {
	result.copyFrom(start);

	if (start.isValid()) {
		if (basicBlock.isExceptionHandler()) {
			CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
			ObjectType catchType = exceptionGen.getCatchType();
			if (catchType == null) {
				// Probably a finally block, or a synchronized block
				// exception-compensation catch block.
				result.pushFinally();
			} else {
				// Catch type was explicitly specified:
				// this is probably a programmer-written catch block
				result.pushCatch();
			}
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:BlockTypeAnalysis.java

示例2: transfer

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, BlockType start, BlockType result)
        throws DataflowAnalysisException {
    result.copyFrom(start);

    if (start.isValid()) {
        if (basicBlock.isExceptionHandler()) {
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            ObjectType catchType = exceptionGen.getCatchType();
            if (catchType == null) {
                // Probably a finally block, or a synchronized block
                // exception-compensation catch block.
                result.pushFinally();
            } else {
                // Catch type was explicitly specified:
                // this is probably a programmer-written catch block
                result.pushCatch();
            }
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:21,代码来源:BlockTypeAnalysis.java

示例3: ExceptionHandlers

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
/**
 * Constructor. Creates a new ExceptionHandlers instance.
 * @param mg
 */
public ExceptionHandlers(MethodGen mg) {
    exceptionhandlers = new Hashtable<InstructionHandle, HashSet>();
    CodeExceptionGen[] cegs = mg.getExceptionHandlers();
    for (CodeExceptionGen ceg : cegs) {
        ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC());
        for (InstructionHandle ih = ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih = ih.getNext()) {
            HashSet<ExceptionHandler> hs;
            hs = exceptionhandlers.get(ih);
            if (hs == null) {
                hs = new HashSet<ExceptionHandler>();
                exceptionhandlers.put(ih, hs);
            }
            hs.add(eh);
        }
    }
}
 
开发者ID:miuirussia,项目名称:KJBE,代码行数:21,代码来源:ExceptionHandlers.java

示例4: meetInto

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
public void meetInto(BetterTypeFrame fact, Edge edge, BetterTypeFrame result)
        throws DataflowAnalysisException {

	// TODO: implement ACCURATE_EXCEPTIONS

	if (fact.isValid() && edge.getTarget().isExceptionHandler()) {
		BetterTypeFrame tmpFact = null;

		// Exception handler.
		// Clear stack and push exception handler catch type.

		tmpFact = modifyFrame(fact, tmpFact);
		tmpFact.clearStack();

		CodeExceptionGen exceptionGen = edge.getTarget().getExceptionGen();
		org.apache.bcel.generic.ObjectType catchType = exceptionGen.getCatchType();
		if (catchType == null) {
			tmpFact.pushValue(typeRepository.classTypeFromSignature(JAVA_LANG_THROWABLE_SIGNATURE));
		} else {
			tmpFact.pushValue(typeRepository.classTypeFromDottedClassName(catchType.getClassName()));
		}

		fact = tmpFact;
	}

	mergeInto(fact, result);

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

示例5: getEndOfCatchBlock

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
static InstructionHandle getEndOfCatchBlock(MethodGen m,
    CodeExceptionGen catchBlock) {

if (catchBlock.getCatchType() == null) {
    // finally clause, no local variable!
    return null;
}

LocalVariableGen[] lt = m.getLocalVariables();

InstructionHandle handler = catchBlock.getHandlerPC();

for (int i = 0; i < lt.length; i++) {
    InstructionHandle start = lt[i].getStart();
    InstructionHandle end = lt[i].getEnd();

    // dangerous, javac is one instruction further...
    if ((start == handler || start == handler.getNext() || start == handler
	    .getNext().getNext())
	    && lt[i].getType().equals(catchBlock.getCatchType())) {
	// System.out.println("found range of catch block: "
	// + handler + " - " + end);
	return end.getPrev();
    }
}

System.err
	.println("Could not find end of catch block, did you compile "
		+ "with the '-g' option?");
System.exit(1);
return null;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:33,代码来源:MethodTable.java

示例6: insertTypecheckCode

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
InstructionHandle insertTypecheckCode(MethodGen m, InstructionList il,
    InstructionHandle pos, int spawnId, int exceptionPos) {
    ArrayList<CodeExceptionGen> catches = mtab.getCatchTypes(m, spawnId);

    InstructionHandle[] jumpTargets = new InstructionHandle[catches.size() + 1];

    BranchHandle[] jumps = new BranchHandle[catches.size()];

    for (int i = 0; i < catches.size(); i++) {
        CodeExceptionGen e = catches.get(i);
        ObjectType type = e.getCatchType();
        InstructionHandle catchTarget = e.getHandlerPC();

        jumpTargets[i] = il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, new INSTANCEOF(cpg.addClass(type)));
        il.insert(pos, new BIPUSH((byte) 1));
        jumps[i] = il.insert(pos, new IF_ICMPNE(null));
        il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, ins_f.createCheckCast(type));
        il.insert(pos, new GOTO(catchTarget));
    }

    InstructionHandle t = il.insert(pos, new ALOAD(exceptionPos));
    il.insert(pos, new ATHROW());

    jumpTargets[catches.size()] = t;

    for (int i = 0; i < catches.size(); i++) {
        jumps[i].setTarget(jumpTargets[i + 1]);
    }

    return pos;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:34,代码来源:Cashmerec.java

示例7: hasRightType

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
private boolean hasRightType(CodeExceptionGen codeException, MethodGen method) {
ObjectType catchType = codeException.getCatchType();
if (catchType == null) return false;
String[] exceptionTypeNames = method.getExceptions();
ObjectType[] exceptionTypes = new ObjectType[exceptionTypeNames.length];
for (int i = 0; i < exceptionTypeNames.length; i++) {
    exceptionTypes[i] = new ObjectType(exceptionTypeNames[i]);
}
return containsType(catchType, exceptionTypes);
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:11,代码来源:SpawningMethod.java

示例8: updateExceptionHandlers

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
private void updateExceptionHandlers() {
    CodeExceptionGen[] handlers = _mg.getExceptionHandlers();
    for (int i = 0; i < handlers.length; i++) {
        CodeExceptionGen h = handlers[i];
        String type = (h.getCatchType() == null) ? "null" : BCELifier.printType(h
                .getCatchType());
        _out.println("    method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition()
                + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_"
                + h.getHandlerPC().getPosition() + ", " + type + ");");
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:12,代码来源:BCELFactory.java

示例9: meetInto

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
public void meetInto(TypeFrame fact, Edge edge, TypeFrame result) throws DataflowAnalysisException {
    BasicBlock basicBlock = edge.getTarget();

    if (fact.isValid()) {
        TypeFrame tmpFact = null;

        // Handling an exception?
        if (basicBlock.isExceptionHandler()) {
            tmpFact = modifyFrame(fact, tmpFact);

            // Special case: when merging predecessor facts for entry to
            // an exception handler, we clear the stack and push a
            // single entry for the exception object. That way, the locals
            // can still be merged.
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            tmpFact.clearStack();

            // Determine the type of exception(s) caught.
            Type catchType = null;

            if (FORCE_ACCURATE_EXCEPTIONS
                    || AnalysisContext.currentAnalysisContext().getBoolProperty(AnalysisFeatures.ACCURATE_EXCEPTIONS)) {
                try {
                    // Ideally, the exceptions that can be propagated
                    // on this edge has already been computed.
                    CachedExceptionSet cachedExceptionSet = getCachedExceptionSet(edge.getSource());
                    ExceptionSet edgeExceptionSet = cachedExceptionSet.getEdgeExceptionSet(edge);
                    if (!edgeExceptionSet.isEmpty()) {
                        // System.out.println("Using computed edge exception set!");
                        catchType = ExceptionObjectType.fromExceptionSet(edgeExceptionSet);
                    }
                } catch (ClassNotFoundException e) {
                    lookupFailureCallback.reportMissingClass(e);
                }
            }

            if (catchType == null) {
                // No information about propagated exceptions, so
                // pick a type conservatively using the handler catch type.
                catchType = exceptionGen.getCatchType();
                if (catchType == null)
                    catchType = Type.THROWABLE; // handle catches anything
                                                // throwable
            }

            tmpFact.pushValue(catchType);
        }

        // See if we can make some types more precise due to
        // a successful instanceof check in the source block.
        if (valueNumberDataflow != null) {
            tmpFact = handleInstanceOfBranch(fact, tmpFact, edge);
        }

        if (tmpFact != null) {
            fact = tmpFact;
        }
    }

    mergeInto(fact, result);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:62,代码来源:TypeAnalysis.java

示例10: computeEdgeExceptionSet

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
/**
 * Based on the set of exceptions that can be thrown from the source basic
 * block, compute the set of exceptions that can propagate along given
 * exception edge. This method should be called for each outgoing exception
 * edge in sequence, so the caught exceptions can be removed from the thrown
 * exception set as needed.
 * 
 * @param edge
 *            the exception edge
 * @param thrownExceptionSet
 *            current set of exceptions that can be thrown, taking earlier
 *            (higher priority) exception edges into account
 * @return the set of exceptions that can propagate along this edge
 */
private ExceptionSet computeEdgeExceptionSet(Edge edge, ExceptionSet thrownExceptionSet) {

    if (thrownExceptionSet.isEmpty())
        return thrownExceptionSet;
    ExceptionSet result = exceptionSetFactory.createExceptionSet();

    if (edge.getType() == UNHANDLED_EXCEPTION_EDGE) {
        // The unhandled exception edge always comes
        // after all of the handled exception edges.
        result.addAll(thrownExceptionSet);
        thrownExceptionSet.clear();
        return result;
    }

    BasicBlock handlerBlock = edge.getTarget();
    CodeExceptionGen handler = handlerBlock.getExceptionGen();
    ObjectType catchType = handler.getCatchType();

    if (Hierarchy.isUniversalExceptionHandler(catchType)) {
        result.addAll(thrownExceptionSet);
        thrownExceptionSet.clear();
    } else {
        // Go through the set of thrown exceptions.
        // Any that will DEFINITELY be caught be this handler, remove.
        // Any that MIGHT be caught, but won't definitely be caught,
        // remain.

        for (ExceptionSet.ThrownExceptionIterator i = thrownExceptionSet.iterator(); i.hasNext();) {
            // ThrownException thrownException = i.next();
            ObjectType thrownType = i.next();
            boolean explicit = i.isExplicit();

            if (DEBUG)
                System.out.println("\texception type " + thrownType + ", catch type " + catchType);

            try {
                if (Hierarchy.isSubtype(thrownType, catchType)) {
                    // Exception can be thrown along this edge
                    result.add(thrownType, explicit);

                    // And it will definitely be caught
                    i.remove();

                    if (DEBUG)
                        System.out.println("\tException is subtype of catch type: " + "will definitely catch");
                } else if (Hierarchy.isSubtype(catchType, thrownType)) {
                    // Exception possibly thrown along this edge
                    result.add(thrownType, explicit);

                    if (DEBUG)
                        System.out.println("\tException is supertype of catch type: " + "might catch");
                }
            } catch (ClassNotFoundException e) {
                // As a special case, if a class hierarchy lookup
                // fails, then we will conservatively assume that the
                // exception in question CAN, but WON'T NECESSARILY
                // be caught by the handler.
                AnalysisContext.reportMissingClass(e);
                result.add(thrownType, explicit);
            }
        }
    }

    return result;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:80,代码来源:TypeAnalysis.java

示例11: visitCode

import org.apache.bcel.generic.CodeExceptionGen; //导入方法依赖的package包/类
public void visitCode(Code code) {
	MethodGen mg = new MethodGen(_method, clazzname, cp);
	InstructionList il = mg.getInstructionList();
	InstructionHandle[] ihs = il.getInstructionHandles();

	LocalVariableGen[] lvs = mg.getLocalVariables();

	CodeExceptionGen[] ehs = mg.getExceptionHandlers();

	for (int i = 0; i < lvs.length; i++) {
		LocalVariableGen l = lvs[i];
		out.println("    // local variable " + l.getIndex() + " is \"" + l.getName()
				+ "\" " + l.getType() + " from "
				+ l.getStart().getPosition() + " to "
				+ l.getEnd().getPosition());
	}

	out.print("\n");

	for (int i = 0; i < ihs.length; i++) {
		InstructionHandle ih = ihs[i];
		Instruction inst = ih.getInstruction();

		out.print("    " + ih.getPosition());

		if (inst instanceof BranchInstruction) {
			if (inst instanceof Select) { // Special cases LOOKUPSWITCH and
										  // TABLESWITCH
				Select s = (Select) inst;
				int[] matchs = s.getMatchs();
				InstructionHandle[] targets = s.getTargets();

				if (s instanceof TABLESWITCH) {
					out.println("  tableswitch " + matchs[0] + " "
							+ matchs[matchs.length - 1]);

					for (int j = 0; j < targets.length; j++)
						out.println("        " + targets[j].getPosition());

				} else { // LOOKUPSWITCH
					out.println("  lookupswitch ");

					for (int j = 0; j < targets.length; j++)
						out.println("        " + matchs[j] + " : "
								+ targets[j].getPosition());
				}

				out.println("        default: " + s.getTarget()); // Applies
																  // for
																  // both
			} else {
				BranchInstruction bi = (BranchInstruction) inst;
				ih = bi.getTarget();
				//str = get(ih);
				out.println("  " + Constants.OPCODE_NAMES[bi.getOpcode()]
						+ " " + ih);
			}
		} else
			out.println("  " + inst.toString(cp.getConstantPool()));
	}

	out.print("\n");

	for (int i = 0; i < ehs.length; i++) {
		CodeExceptionGen c = ehs[i];
		ObjectType caught = c.getCatchType();
		String class_name = (caught == null) ? // catch any exception, used
											   // when compiling finally
				"all" : caught.getClassName().replace('.', '/');

		out.println("    catch " + class_name + " from "
				+ c.getStartPC().getPosition() + " to "
				+ c.getEndPC().getPosition() + " using "
				+ c.getHandlerPC().getPosition());
	}
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:77,代码来源:DecompilingVisitor.java


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