本文整理汇总了Java中org.objectweb.asm.tree.TryCatchBlockNode类的典型用法代码示例。如果您正苦于以下问题:Java TryCatchBlockNode类的具体用法?Java TryCatchBlockNode怎么用?Java TryCatchBlockNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TryCatchBlockNode类属于org.objectweb.asm.tree包,在下文中一共展示了TryCatchBlockNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SnippetCode
import org.objectweb.asm.tree.TryCatchBlockNode; //导入依赖的package包/类
public SnippetCode(InsnList instructions,
List<TryCatchBlockNode> tryCatchBlocks,
Set<SyntheticLocalVar> referencedSLV,
Set<ThreadLocalVar> referencedTLV,
boolean containsHandledException,
Set<StaticContextMethod> staticContexts,
boolean usesDynamicContext,
boolean usesClassContext,
boolean usesProcessorContext,
Map<Integer, ProcInvocation> invokedProcessors
) {
super(instructions, tryCatchBlocks, referencedSLV, referencedTLV,
staticContexts, usesDynamicContext, usesClassContext,
containsHandledException);
this.invokedProcessors = invokedProcessors;
this.usesProcessorContext = usesProcessorContext;
}
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:19,代码来源:SnippetCode.java
示例17: __cloneTryCatchBlocks
import org.objectweb.asm.tree.TryCatchBlockNode; //导入依赖的package包/类
private static List <TryCatchBlockNode> __cloneTryCatchBlocks (
final List <TryCatchBlockNode> tryCatchBlocks,
final Map <LabelNode, LabelNode> replacementLabels
) {
final List <TryCatchBlockNode> result = new LinkedList <TryCatchBlockNode> ();
for (final TryCatchBlockNode tcb : tryCatchBlocks) {
final TryCatchBlockNode tcbClone = new TryCatchBlockNode (
replacementLabels.get (tcb.start),
replacementLabels.get (tcb.end),
replacementLabels.get (tcb.handler),
tcb.type
);
result.add (tcbClone);
}
return result;
}
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:18,代码来源:AsmHelper.java
示例18: sort
import org.objectweb.asm.tree.TryCatchBlockNode; //导入依赖的package包/类
public void sort() {
if (this.methodNode.tryCatchBlocks == null) {
return;
}
Collections.sort(this.methodNode.tryCatchBlocks, new Comparator<TryCatchBlockNode>() {
@Override
public int compare(TryCatchBlockNode o1, TryCatchBlockNode o2) {
return blockLength(o1) - blockLength(o2);
}
private int blockLength(TryCatchBlockNode block) {
final int startidx = methodNode.instructions.indexOf(block.start);
final int endidx = methodNode.instructions.indexOf(block.end);
return endidx - startidx;
}
});
// Updates the 'target' of each try catch block annotation.
for (int i = 0; i < this.methodNode.tryCatchBlocks.size(); i++) {
this.methodNode.tryCatchBlocks.get(i).updateIndex(i);
}
}
开发者ID:naver,项目名称:pinpoint,代码行数:24,代码来源:ASMTryCatch.java
示例19: printMethod
import org.objectweb.asm.tree.TryCatchBlockNode; //导入依赖的package包/类
public static void printMethod(PrintStream out, MethodNode method) {
final Textifier textifier = new Textifier();
final TraceMethodVisitor mv = new TraceMethodVisitor(textifier);
out.println(method.name + method.desc);
for (int j = 0; j < method.instructions.size(); ++j) {
method.instructions.get(j).accept(mv);
final StringBuffer s = new StringBuffer();
while (s.length() < method.maxStack + method.maxLocals + 1) {
s.append(' ');
}
out.print(Integer.toString(j + 100000).substring(1));
out.print(" " + s + " : " + textifier.text.get(j));
}
for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
out.print(" " + textifier.text.get(method.instructions.size()+j));
}
out.println(" MAXSTACK " + method.maxStack);
out.println(" MAXLOCALS " + method.maxLocals);
out.println();
}
开发者ID:hammacher,项目名称:javaslicer,代码行数:24,代码来源:Transformer.java
示例20: 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:nxmatic,项目名称:objectweb-asm-4.0,代码行数:28,代码来源:JSRInlinerAdapter.java
注:本文中的org.objectweb.asm.tree.TryCatchBlockNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论