List of usage examples for org.objectweb.asm.tree LabelNode LabelNode
public LabelNode(final Label label)
From source file:cl.inria.stiq.instrumenter.LocationsManager.java
License:Open Source License
/** * Creates a new location at the end of the given list. *///from w ww .j a va2s.co m public int createLocation(InsnList aInsns) { int theId = itsStructureDatabase.addProbe(-1, -1, null, -1); Label theLabel = new Label(); aInsns.add(new LabelNode(theLabel)); itsLocations.add(new TmpLocationInfo(theId, theLabel)); return theId; }
From source file:cl.inria.stiq.instrumenter.LocationsManager.java
License:Open Source License
/** * Creates a new location before the given node in the given list. *//*from w w w . j a va 2s . co m*/ public int createLocation(InsnList aInsns, AbstractInsnNode aNode) { int theId = itsStructureDatabase.addProbe(-1, -1, null, -1); Label theLabel = new Label(); aInsns.insertBefore(aNode, new LabelNode(theLabel)); itsLocations.add(new TmpLocationInfo(theId, theLabel)); return theId; }
From source file:com.dragome.callbackevictor.serverside.bytecode.transformation.asm.ContinuationMethodAnalyzer.java
License:Apache License
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { MethodInsnNode mnode = new MethodInsnNode(opcode, owner, name, desc, itf); if (opcode == INVOKESPECIAL || "<init>".equals(name)) { methods.add(mnode);// w w w. ja va2 s.c o m } if (needsFrameGuard(opcode, owner, name, desc) /* && transformer.inScope(owner, name)*/) { Label label = new Label(); super.visitLabel(label); LabelNode labelNode = new LabelNode(label); instructions.add(labelNode); labels.add(label); nodes.add(mnode); //RS: if (_continueReflection && name.equals("invoke") && owner.startsWith("java/lang/reflect/Method")) { int mthd = ((Integer) _variables.get(_variables.size() - 3)).intValue(); int obj = ((Integer) _variables.get(_variables.size() - 2)).intValue(); int args = ((Integer) _variables.get(_variables.size() - 1)).intValue(); MyVariables vars = new MyVariables(mthd, obj, args); _reflectMapping.put(mnode, vars); } //RS: } instructions.add(mnode); }
From source file:com.facebook.swift.codec.internal.compiler.byteCode.MethodDefinition.java
License:Apache License
private LabelNode getLabel(String name) { Label label = labels.get(name); if (label == null) { label = new Label(); labels.put(name, label);// ww w. j av a2s. co m } return new LabelNode(label); }
From source file:com.github.fge.grappa.transform.CodeBlock.java
License:Apache License
public CodeBlock visitLabel(Label label) { instructionList.add(new LabelNode(label)); return this; }
From source file:com.mogujie.instantrun.IncrementalSupportVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { AcesoProguardMap.instance().putMethod(visitedClassName, IncrementalTool.getMtdSig(name, desc)); access = IncrementalTool.transformAccessForInstantRun(access); MethodVisitor defaultVisitor = super.visitMethod(access, name, desc, signature, exceptions); MethodNode method = getMethodByNameInClass(name, desc, classNode); // does the method use blacklisted APIs. boolean hasIncompatibleChange = InstantRunMethodVerifier.verifyMethod(method); if (hasIncompatibleChange || disableRedirectionForClass || !isAccessCompatibleWithInstantRun(access) || name.equals(ByteCodeUtils.CLASS_INITIALIZER)) { return defaultVisitor; } else {/*w w w . j a v a 2 s . co m*/ ArrayList<Type> args = new ArrayList<Type>(Arrays.asList(Type.getArgumentTypes(desc))); boolean isStatic = (access & Opcodes.ACC_STATIC) != 0; if (!isStatic) { args.add(0, Type.getType(Object.class)); } ISMethodVisitor mv = new ISMethodVisitor(defaultVisitor, access, name, desc); if (name.equals(ByteCodeUtils.CONSTRUCTOR)) { } else { mv.addRedirection(new MethodRedirection(new LabelNode(mv.getStartLabel()), visitedClassName, name, desc, args, Type.getReturnType(desc), isStatic)); } method.accept(mv); return null; } }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
public static Map<LabelNode, LabelNode> cloneLabels(InsnList source) { Map<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>(); for (Iterator<AbstractInsnNode> iter = source.iterator(); iter.hasNext();) { AbstractInsnNode insn = iter.next(); if (insn instanceof LabelNode) { labels.put((LabelNode) insn, new LabelNode(((LabelNode) insn).getLabel())); }/*www .j a v a 2 s .c o m*/ } return labels; }
From source file:de.unisb.cs.st.javalanche.mutation.bytecodeMutations.removeSystemExit.RemoveSystemExitMethodNode.java
License:Open Source License
@SuppressWarnings("unchecked") // Call to pre-1.5 Code @Override//www. j a v a 2 s . c o m public void visitEnd() { MethodNode mn = (MethodNode) mv; InsnList insns = mn.instructions; Iterator i = insns.iterator(); AbstractInsnNode prev = null; InsnList newInstrucionList = new InsnList(); while (i.hasNext()) { boolean addInstruction = true; AbstractInsnNode i1 = (AbstractInsnNode) i.next(); if (i1 instanceof MethodInsnNode) { MethodInsnNode methotInsnNode = (MethodInsnNode) i1; if (methotInsnNode.name.equals("exit") && methotInsnNode.owner.equals("java/lang/System")) { logger.info("Replacing System.exit "); newInstrucionList.remove(prev); // insns.remove(i1); InsnList il = new InsnList(); Label mutationStartLabel = new Label(); mutationStartLabel.info = new MutationMarker(true); il.add(new LabelNode(mutationStartLabel)); il.add(new TypeInsnNode(Opcodes.NEW, "java/lang/RuntimeException")); il.add(new InsnNode(Opcodes.DUP)); il.add(new LdcInsnNode("Replaced System.exit()")); il.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V")); il.add(new InsnNode(Opcodes.ATHROW)); Label mutationEndLabel = new Label(); mutationEndLabel.info = new MutationMarker(false); il.add(new LabelNode(mutationEndLabel)); newInstrucionList.add(il); addInstruction = false; } } if (addInstruction) { try { insns.remove(i1); newInstrucionList.add(i1); } catch (Exception e) { logger.error(e); } } prev = i1; } mn.instructions = newInstrucionList; mn.accept(next); }
From source file:edu.mit.streamjit.util.bytecode.MethodUnresolver.java
License:Open Source License
private void createLabels() { for (BasicBlock b : method.basicBlocks()) labels.put(b, new LabelNode(new Label())); }
From source file:edu.ubc.mirrors.holograms.FrameAnalyzerAdaptor.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { final MethodVisitor superVisitor = super.visitMethod(access, name, desc, signature, exceptions); final Map<Label, LabelNode> labelNodes = new HashMap<Label, LabelNode>(); final FrameVerifier verifier = new FrameVerifier(vm, loader, holograms); MethodNode analyzer = new MethodNode(access, name, desc, null, null) { @Override/*from w w w . j a v a 2 s . com*/ public void visitEnd() { FrameAnalyzer a = new FrameAnalyzer(verifier); Frame<FrameValue>[] frames = null; try { frames = a.analyze(thisType.getInternalName(), this); if (superVisitor != null) { if (insertFrames) { frames = a.insertFrames(); } accept(superVisitor); } } catch (Throwable e) { if (e instanceof IndexOutOfBoundsException && maxLocals == 0 && maxStack == 0) { throw new RuntimeException( "Data flow checking option requires valid, non zero maxLocals and maxStack values."); } if (frames == null) { frames = a.getFrames(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); printAnalyzerResult(this, frames, pw); pw.close(); throw new RuntimeException(sw.toString(), e); } } @Override protected LabelNode getLabelNode(Label l) { LabelNode node = labelNodes.get(l); if (node == null) { node = new LabelNode(l); labelNodes.put(l, node); } return node; } }; analyzer.instructions = new FrameInsnList(); // Inline subroutines since other pieces of the pipeline can't handle them return new JSRInlinerAdapter(analyzer, access, name, desc, signature, exceptions); }