當前位置: 首頁>>代碼示例>>Java>>正文


Java TryCatchBlockNode類代碼示例

本文整理匯總了Java中org.objectweb.asm.tree.TryCatchBlockNode的典型用法代碼示例。如果您正苦於以下問題:Java TryCatchBlockNode類的具體用法?Java TryCatchBlockNode怎麽用?Java TryCatchBlockNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TryCatchBlockNode類屬於org.objectweb.asm.tree包,在下文中一共展示了TryCatchBlockNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: emitCode

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
/**
 * Creates the new instructions, inlining each instantiation of each
 * subroutine until the code is fully elaborated.
 */
private void emitCode() {
    LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
    // Create an instantiation of the "root" subroutine, which is just the
    // main routine
    worklist.add(new Instantiation(null, mainSubroutine));

    // Emit instantiations of each subroutine we encounter, including the
    // main subroutine
    InsnList newInstructions = new InsnList();
    List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
    List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
    while (!worklist.isEmpty()) {
        Instantiation inst = worklist.removeFirst();
        emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
                newLocalVariables);
    }
    instructions = newInstructions;
    tryCatchBlocks = newTryCatchBlocks;
    localVariables = newLocalVariables;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:25,代碼來源:JSRInlinerAdapter.java

示例2: getEntryPoints

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
	InsnList il = asmNode.instructions;
	BitSet entryPoints = new BitSet(il.size());

	for (int[] eps : exitPoints.values()) {
		if (eps != null) {
			for (int ep : eps) entryPoints.set(ep);
		}
	}

	for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
		entryPoints.set(il.indexOf(n.handler));
	}

	return entryPoints;
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:17,代碼來源:Analysis.java

示例3: visitEnd

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:27,代碼來源:TryCatchBlockSorter.java

示例4: filterCatchVariables

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
@SuppressWarnings(UNCHECKED)
private void filterCatchVariables() {
	// on supprime les variables des blocs catchs (comme eclipse, etc...),
	// avant de supprimer les doublons car les blocs catchs provoquent parfois des variables de même index
	for (final TryCatchBlockNode tryCatchBlock : (List<TryCatchBlockNode>) methodNode.tryCatchBlocks) {
		// TODO est-ce qu'il y a un meilleur moyen d'identifier la variable de l'exception autrement que par son type ?
		final String type = tryCatchBlock.type;
		// type est null si finally
		if (type != null) {
			for (final Iterator<LocalVariableNode> it = localVariables.iterator(); it
					.hasNext();) {
				final LocalVariableNode localVariable = it.next();
				final Type typeLocalVariable = Type.getType(localVariable.desc);
				if (typeLocalVariable.getSort() == Type.OBJECT
						&& type.equals(typeLocalVariable.getInternalName())) {
					it.remove();
					break;
				}
			}
		}
	}
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:23,代碼來源:LocalVariablesAnalyzer.java

示例5: exception

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
/** Adds an exception try block node to this graph */
protected void exception(@NonNull AbstractInsnNode from, @NonNull TryCatchBlockNode tcb) {
    // Add tcb's to all instructions in the range
    LabelNode start = tcb.start;
    LabelNode end = tcb.end; // exclusive

    // Add exception edges for all method calls in the range
    AbstractInsnNode curr = start;
    Node handlerNode = getNode(tcb.handler);
    while (curr != end && curr != null) {
        if (curr.getType() == AbstractInsnNode.METHOD_INSN) {
            // Method call; add exception edge to handler
            if (tcb.type == null) {
                // finally block: not an exception path
                getNode(curr).addSuccessor(handlerNode);
            }
            getNode(curr).addExceptionPath(handlerNode);
        }
        curr = curr.getNext();
    }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:ControlFlowGraph.java

示例6: newInstance

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
/**
 * Creates a new instance and initializes the manager
 * @param tryCatchBlocks list of {@link TryCatchBlockNode}s
 * @param stack expression stack, used for creation of label ids
 * @return initialized TryCatchManager
 */
public static TryCatchManager newInstance(List tryCatchBlocks, ExpressionStack stack) {
	TryCatchManager manager = new TryCatchManager();
	List<Item> tryCatchItems = new ArrayList<>();
	List<Item> catchBlockHandlers = new ArrayList<>();
	if (tryCatchBlocks != null) {
		for (Object block : tryCatchBlocks) {
			TryCatchBlockNode node = (TryCatchBlockNode) block;
			Item item = new Item(stack.getLabelId(node.start.getLabel()), stack.getLabelId(node.end.getLabel()),
					stack.getLabelId(node.handler.getLabel()), node.type);
			addNewItemToList(tryCatchItems, catchBlockHandlers, item);
		}
	}
	manager.setItems(tryCatchItems);
	manager.setCatchBlockHandlers(catchBlockHandlers);
	return manager;
}
 
開發者ID:JozefCeluch,項目名稱:thesis-disassembler,代碼行數:23,代碼來源:TryCatchManager.java

示例7: addCatchBlock

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
private void addCatchBlock(LabelNode startNode, LabelNode endNode) {

        InsnList il = new InsnList();
        LabelNode handlerNode = new LabelNode();
        il.add(handlerNode);

        int exceptionVariablePosition = getFistAvailablePosition();
        il.add(new VarInsnNode(Opcodes.ASTORE, exceptionVariablePosition));
        this.methodOffset++; // Actualizamos el offset
        addGetCallback(il);
        il.add(new VarInsnNode(Opcodes.ALOAD, this.methodVarIndex));
        il.add(new VarInsnNode(Opcodes.ALOAD, exceptionVariablePosition));
        il.add(new VarInsnNode(Opcodes.ALOAD, this.executionIdIndex));
        il.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
                "org/brutusin/instrumentation/Callback", "onThrowableUncatched",
                "(Ljava/lang/Object;Ljava/lang/Throwable;Ljava/lang/String;)V", false));

        il.add(new VarInsnNode(Opcodes.ALOAD, exceptionVariablePosition));
        il.add(new InsnNode(Opcodes.ATHROW));

        TryCatchBlockNode blockNode = new TryCatchBlockNode(startNode, endNode, handlerNode, null);

        this.mn.tryCatchBlocks.add(blockNode);
        this.mn.instructions.add(il);
    }
 
開發者ID:brutusin,項目名稱:instrumentation,代碼行數:26,代碼來源:Instrumentator.java

示例8: visitEnd

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    if (mv != null) {
        accept(mv);
    }
}
 
開發者ID:bcleenders,項目名稱:Bramspr,代碼行數:23,代碼來源:TryCatchBlockSorter.java

示例9: containsHandledException

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
/**
 * Determines if the code contains handler that handles exception and
 * doesn't propagate some exception further.
 *
 * This has to be detected because it can cause stack inconsistency that has
 * to be handled in the weaver.
 */
private boolean containsHandledException(InsnList instructions,
        List<TryCatchBlockNode> tryCatchBlocks) {

    if (tryCatchBlocks.size() == 0) {
        return false;
    }

    // create control flow graph
    CtrlFlowGraph cfg = new CtrlFlowGraph(instructions, tryCatchBlocks);
    cfg.visit(instructions.getFirst());

    // check if the control flow continues after exception handler
    // if it does, exception was handled
    for (int i = tryCatchBlocks.size() - 1; i >= 0; --i) {

        TryCatchBlockNode tcb = tryCatchBlocks.get(i);

        if (cfg.visit(tcb.handler).size() != 0) {
            return true;
        }
    }

    return false;
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:32,代碼來源:UnprocessedCode.java

示例10: Code

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
/**
 * Constructs the Code structure.
 */
public Code(InsnList instructions, List<TryCatchBlockNode> tryCatchBlocks,
        Set<SyntheticLocalVar> referencedSLVs,
        Set<ThreadLocalVar> referencedTLVs,
        Set<StaticContextMethod> staticContexts,
        boolean usesDynamicContext,
        boolean usesClassContext,
        boolean containsHandledException) {
    super();
    this.instructions = instructions;
    this.tryCatchBlocks = tryCatchBlocks;
    this.referencedSLVs = referencedSLVs;
    this.referencedTLVs = referencedTLVs;
    this.staticContexts = staticContexts;
    this.usesDynamicContext = usesDynamicContext;
    this.usesClassContext = usesClassContext;
    this.containsHandledException = containsHandledException;
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:21,代碼來源:Code.java

示例11: visitEnd

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(Insns.FORWARD.firstRealInsn (block.start));
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };

    Collections.sort(tryCatchBlocks, comp);
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:20,代碼來源:AdvancedSorter.java

示例12: removeUnusedHandler

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
private boolean removeUnusedHandler() {

        CtrlFlowGraph cfg = CtrlFlowGraph.build(method);
        boolean isOptimized = false;

        for (final TryCatchBlockNode tcb : method.tryCatchBlocks) {
            // TCB start is inclusive, TCB end is exclusive.
            final AbstractInsnNode first = Insns.FORWARD.firstRealInsn (tcb.start);
            final AbstractInsnNode last = Insns.REVERSE.nextRealInsn (tcb.end);
            if (first == last) {
                method.tryCatchBlocks.remove(tcb);
                isOptimized |= removeUnusedBB(cfg);
            }
        }

        return isOptimized;
    }
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:18,代碼來源:PartialEvaluator.java

示例13: getMaxStack

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
public static int getMaxStack(InsnList ilist,
        List<TryCatchBlockNode> tryCatchBlocks) {

    CtrlFlowGraph cfg = CtrlFlowGraph.build(ilist, tryCatchBlocks);
    List<BasicBlock> unvisited = cfg.getNodes();

    int maxStack = getMaxStack(0, cfg.getBB(ilist.getFirst()), unvisited);

    for (TryCatchBlockNode tcb : tryCatchBlocks) {
        maxStack = Math
                .max(getMaxStack(1, cfg.getBB(tcb.handler), unvisited),
                        maxStack);
    }

    return maxStack;
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:17,代碼來源:MaxCalculator.java

示例14: ProcCode

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
public ProcCode(InsnList instructions,
		List<TryCatchBlockNode> tryCatchBlocks,
		Set<SyntheticLocalVar> referencedSLV,
		Set<ThreadLocalVar> referencedTLV,
		boolean containsHandledException,
		Set<StaticContextMethod> staticContexts,
		boolean usesDynamicContext,
		boolean usesClassContext,
		boolean usesArgumentContext
		) {
	
	super(instructions, tryCatchBlocks, referencedSLV, referencedTLV,
			staticContexts, usesDynamicContext, usesClassContext,
			containsHandledException);
	this.usesArgumentContext = usesArgumentContext;
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:17,代碼來源:ProcCode.java

示例15: markWithDefaultWeavingReg

import org.objectweb.asm.tree.TryCatchBlockNode; //導入依賴的package包/類
@Override
public List<MarkedRegion> markWithDefaultWeavingReg(MethodNode method) {

    List<MarkedRegion> regions = new LinkedList<MarkedRegion>();

    for (TryCatchBlockNode tcb : method.tryCatchBlocks) {

        AbstractInsnNode start = Insns.FORWARD.firstRealInsn (tcb.start);
        // RFC LB: Consider nextRealInsn, since TCB end is exclusive
        // This depends on the semantics of marked region
        AbstractInsnNode end = Insns.REVERSE.firstRealInsn (tcb.end);
        regions.add(new MarkedRegion(start, end));
    }

    return regions;
}
 
開發者ID:mur47x111,項目名稱:svm-fasttagging,代碼行數:17,代碼來源:TryClauseMarker.java


注:本文中的org.objectweb.asm.tree.TryCatchBlockNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。