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


Java InsnList.insertBefore方法代码示例

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


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

示例1: callLast

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public ImagineMethod callLast(final String owner, final String methodName) {
    final InsnList instructions = this.mMethod.instructions;
    final InsnList methodCall = methodCall(this, owner, methodName, owner != null, false);
    for (final AbstractInsnNode node : instructions) {
        switch (node.getOpcode()) {
            case 172:
            case 173:
            case 174:
            case 175:
            case 176:
            case 177: {
                instructions.insertBefore(node, methodCall);
                continue;
            }
        }
    }
    return this;
}
 
开发者ID:CyberdyneCC,项目名称:ThermosRebased,代码行数:19,代码来源:ImagineMethod.java

示例2: addTraceReturn

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void addTraceReturn() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.RETURN:
                    il.insertBefore(abstractInsnNode, getVoidReturnTraceInstructions());
                    break;
                case Opcodes.IRETURN:
                case Opcodes.LRETURN:
                case Opcodes.FRETURN:
                case Opcodes.ARETURN:
                case Opcodes.DRETURN:
                    il.insertBefore(abstractInsnNode, getReturnTraceInstructions());
            }
        }
    }
 
开发者ID:brutusin,项目名称:instrumentation,代码行数:22,代码来源:Instrumentator.java

示例3: addTraceThrow

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void addTraceThrow() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.ATHROW:
                    il.insertBefore(abstractInsnNode, getThrowTraceInstructions());
                    break;
            }
        }

    }
 
开发者ID:brutusin,项目名称:instrumentation,代码行数:17,代码来源:Instrumentator.java

示例4: insertPushNull

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Insert a call to the isNull helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) {
	int branchId = getBranchID(currentMethodNode, position);
	logger.info("Inserting instrumentation for NULL check at branch " + branchId
	        + " in method " + currentMethodNode.name);

	MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isNull",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, nullCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position, branchId);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:31,代码来源:BooleanTestabilityTransformation.java

示例5: insertPushEquals

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Insert a call to the reference equality check helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) {
	MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isEqual",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP2));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, equalCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:28,代码来源:BooleanTestabilityTransformation.java

示例6: insertPush

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Insert a call to the distance function for unary comparison
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPush(int opcode, JumpInsnNode position, InsnList list) {
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	// TODO: We have to put a placeholder here instead of the actual branch ID
	// TODO: And then later add another transformation where we replace this with
	//       actual branch IDs
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:23,代码来源:BooleanTestabilityTransformation.java

示例7: insertPush2

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Insert a call to the distance function for binary comparison
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPush2(int opcode, JumpInsnNode position, InsnList list) {
	list.insertBefore(position, new InsnNode(Opcodes.DUP2));
	//list.insertBefore(position, new InsnNode(Opcodes.ISUB));
	MethodInsnNode sub = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "intSub",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, sub);
	insertBranchIdPlaceholder(currentMethodNode, position);

	//		list.insertBefore(position,
	//		                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:27,代码来源:BooleanTestabilityTransformation.java

示例8: patchNodes

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private boolean patchNodes(MethodNode method) {
    InsnList list = method.instructions;
    boolean patched = false;
    boolean foundUrl = false;

    for(int i = 0; i < list.size(); i++) {
        AbstractInsnNode node = list.get(i);

        if(node instanceof LdcInsnNode) {
            LdcInsnNode ldc = (LdcInsnNode)node;

            if(ldc.cst instanceof String && isUrl((String)ldc.cst)) {
                foundUrl = true;
            }

        } else if(foundUrl && (node.getOpcode() == Opcodes.PUTFIELD || node.getOpcode() == Opcodes.ASTORE)) {

            list.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC,
                    "guichaguri/skinfixer/SkinWorker", "getURL", "(Ljava/lang/String;)Ljava/lang/String;", false));
            foundUrl = false;
            patched = true;

        }

    }
    return patched;
}
 
开发者ID:Guichaguri,项目名称:SkinFixer,代码行数:28,代码来源:SkinTransformer.java

示例9: moveUp

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Moves the insns up one in the list.
 * 
 * @param list
 *            Complete list of opcodes.
 * @param insn
 *            Sublist to be moved.
 */
public static void moveUp(InsnList list, List<AbstractInsnNode> insns) {
	AbstractInsnNode prev = insns.get(0).getPrevious();
	if (prev == null) return;
	InsnList x = new InsnList();
	for (AbstractInsnNode ain : insns) {
		list.remove(ain);
		x.add(ain);
	}
	list.insertBefore(prev, x);
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:19,代码来源:Asm.java

示例10: inject

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void inject(ClassNode var1) {
   Iterator var3 = var1.methods.iterator();

   while(true) {
      MethodNode var2;
      do {
         do {
            if(!var3.hasNext()) {
               return;
            }

            var2 = (MethodNode)var3.next();
         } while(!var2.name.equalsIgnoreCase(this.method));
      } while(!var2.desc.equalsIgnoreCase(this.desc));

      InsnList var4 = var2.instructions;

      try {
         AbstractInsnNode var5 = var4.get(this.startIndex);
         AbstractInsnNode var6 = null;

         for(int var7 = 0; var7 < this.nodes.length; ++var7) {
            if(var6 == null) {
               var4.insertBefore(var5, this.nodes[var7]);
            } else {
               var4.insert(var6, this.nodes[var7]);
            }

            var6 = this.nodes[var7];
         }
      } catch (Exception var8) {
         System.err.println("Failed on " + this.startIndex + " @ " + this.owner + "." + this.method + " " + this.desc);
         var8.printStackTrace();
      }
   }
}
 
开发者ID:runelite,项目名称:runelite,代码行数:37,代码来源:MethodModInstruction.java

示例11: insertBefore

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
protected boolean insertBefore(InsnList nodes, Predicate<AbstractInsnNode> validator, InsnList insert, boolean last) {
    AbstractInsnNode node = last ? this.getNodeLast(nodes, validator) : this.getNode(nodes, validator);
    if (node != null) {
        nodes.insertBefore(node, insert);
        return true;
    }
    return false;
}
 
开发者ID:gegy1000,项目名称:BlockSystems,代码行数:9,代码来源:Transformer.java

示例12: insertGetBefore

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
 * Insert a call that takes a boolean from the stack, and returns the
 * appropriate distance
 * 
 * @param position
 * @param list
 */
public void insertGetBefore(AbstractInsnNode position, InsnList list) {
	logger.info("Inserting get call before");
	// Here, branchId is the first control dependency
	//list.insertBefore(position,
	//                  new LdcInsnNode(getControlDependentBranchID(currentMethodNode,
	//                                                              position)));
	// insertControlDependencyPlaceholder(currentMethodNode, position);

	// branch
	// approx
	// value

	Label label = new Label();
	LabelNode labelNode = new LabelNode(label);
	//BooleanTestabilityPlaceholderTransformer.addControlDependencyPlaceholder(label,
	//                                                                         insnNode);
	currentMethodNode.instructions.insertBefore(position, labelNode);
	//instructions.insertBefore(insnNode, new LdcInsnNode(0));
	//mn.instructions.insertBefore(insnNode, new LdcInsnNode(0));
	currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(
	        getControlDependentBranchID(currentMethodNode, position)));
	currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP));
	currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(
	        getApproximationLevel(currentMethodNode, position)));
	currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP));

	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "getDistance",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE, Type.INT_TYPE }), false);
	list.insertBefore(position, get);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:BooleanTestabilityTransformation.java

示例13: inject

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public byte[] inject(byte[] classfileBuffer) {
	try {
		ClassReader cr = new ClassReader(classfileBuffer);
		ClassNode cn = new ClassNode();
		cr.accept(cn, 0);
		
		ArrayList<AbstractInsnNode> injectPos = new ArrayList<AbstractInsnNode>();
		
		@SuppressWarnings("unchecked")
		List<MethodNode> methods = (List<MethodNode>)cn.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = methods.get(i);
            InsnList instructions = method.instructions;
            if (instructions.size() <= 0)
            	continue;
            
           	//System.out.println("Method: "+method.name+" ");
               for (int j = 0; j < instructions.size(); ++j) {
               	AbstractInsnNode insn = (AbstractInsnNode)instructions.get(j);
                   //System.out.println("\tInsn: opc="+OpcodeUtil.getOpcode(insn.getOpcode())+", type="+insn.getType());
                   if (insn.getType() == AbstractInsnNode.METHOD_INSN) {
               		MethodInsnNode min = (MethodInsnNode)insn;
               		//System.out.printf("\t\towner=%s, name=%s, desc=%s\n", min.owner, min.name, min.desc);
               		
               		if (min.owner.equals("java/net/Socket") && min.name.equals("<init>") && min.desc.equals("()V")) {
               			min.desc = "(Ljava/net/Proxy;)V";
               			injectPos.add(min);
               		}
                   }
            }
            
	        for (int k = 0; k < injectPos.size(); k++) {
	        	AbstractInsnNode pos = injectPos.get(k);
	        	MethodInsnNode newMin = new MethodInsnNode(
	        			Opcodes.INVOKESTATIC,
	        			"ht/misc/injectsocks/ProxyManager",
	        			"getProxy",
	        			"()Ljava/net/Proxy;",
	        			false);
	        	instructions.insertBefore(pos, newMin);
	        }
	        
        }
        
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        cn.accept(cw);
		byte[] injectedClassfileBuffer = cw.toByteArray();
		System.out.printf("INFO: classfileBuffer.legnth=%d, injectedClassfileBuffer.length=%d\n", 
				classfileBuffer.length, injectedClassfileBuffer.length);
		
		return injectedClassfileBuffer;
	} catch (Throwable e) {
		e.printStackTrace();
		return classfileBuffer;
	}
}
 
开发者ID:ralgond,项目名称:injectsocks,代码行数:57,代码来源:InjectSockstTransformerImpl.java

示例14: callFirst

import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public ImagineMethod callFirst(final String owner, final String methodName) {
    final InsnList instructions = this.mMethod.instructions;
    instructions.insertBefore(instructions.getFirst(), methodCall(this, owner, methodName, owner != null, false));
    return this;
}
 
开发者ID:CyberdyneCC,项目名称:ThermosRebased,代码行数:6,代码来源:ImagineMethod.java


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