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


Java Opcodes.RETURN属性代码示例

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


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

示例1: hookMethod

/**
 * (none-javadoc)
 *
 * @see com.fuxi.javaagent.hook.AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor)
 */
@Override
protected MethodVisitor hookMethod(int access, String name, String desc, String signature, String[] exceptions, MethodVisitor mv) {
    if ("<init>".equals(name) && "(Ljava/io/File;)V".equals(desc)) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            public void onMethodExit(int opcode) {
                if (opcode == Opcodes.RETURN) {
                    loadArg(0);
                    invokeStatic(Type.getType(FileInputStreamHook.class),
                            new Method("checkReadFile", "(Ljava/io/File;)V"));
                }
                super.onMethodExit(opcode);
            }
        };
    }
    return mv;
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:22,代码来源:FileInputStreamHook.java

示例2: hookMethod

/**
 * (none-javadoc)
 *
 * @see AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor)
 */
@Override
protected MethodVisitor hookMethod(int access, String name, String desc, String signature, String[] exceptions, MethodVisitor mv) {
    if ("<init>".equals(name) && "(Ljava/io/File;Z)V".equals(desc)) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            public void onMethodExit(int opcode) {
                if (opcode == Opcodes.RETURN) {
                    loadArg(0);
                    invokeStatic(Type.getType(FileOutputStreamHook.class),
                            new Method("checkWriteFile", "(Ljava/io/File;)V"));
                }
                super.onMethodExit(opcode);
            }
        };
    }
    return mv;
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:22,代码来源:FileOutputStreamHook.java

示例3: insert

private void insert() {
    InsnList trInsns = transformerNode.instructions;

    AbstractInsnNode node = trInsns.getLast();

    while (true) {
        if (node == null)
            break;

        if (node instanceof LabelNode) {
            node = node.getPrevious();
            continue;
        } else if (node.getOpcode() == Opcodes.RETURN) {
            trInsns.remove(node);
        } else if (node.getOpcode() == Opcodes.ATHROW && node.getPrevious().getOpcode() == Opcodes.ACONST_NULL) {
            AbstractInsnNode prev = node.getPrevious();
            trInsns.remove(node);
            trInsns.remove(prev);
        }

        break;
    }

    resultNode.instructions.insert(trInsns);
}
 
开发者ID:Yamakaja,项目名称:RuntimeTransformer,代码行数:25,代码来源:MethodJob.java

示例4: addDirectExits

private static void addDirectExits(InsnList il, BitSet entryPoints, Map<AbstractInsnNode, int[]> exitPoints) {
	int idx = 0; // ignore 0 since it has no preceding instruction

	while ((idx = entryPoints.nextSetBit(idx + 1)) != -1) {
		AbstractInsnNode prev = il.get(idx - 1);
		if (exitPoints.containsKey(prev)) continue;
		int type = prev.getType();

		if (prev.getOpcode() != Opcodes.ATHROW
				&& (prev.getOpcode() < Opcodes.IRETURN || prev.getOpcode() > Opcodes.RETURN)
				&& type != AbstractInsnNode.JUMP_INSN
				&& type != AbstractInsnNode.TABLESWITCH_INSN
				&& type != AbstractInsnNode.LOOKUPSWITCH_INSN) {
			exitPoints.put(prev, new int[] { idx });
		}
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:17,代码来源:Analysis.java

示例5: visitInsn

@Override
public void visitInsn(int opcode) {
    //This method can get the operation type of each instruction in the method, which is accessed many times  
    //If a new instruction should be added at the end of the method, it should be judged:  
    if (opcode == Opcodes.RETURN) {
        // pushes the 'out' field (of type PrintStream) of the System class  
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        // pushes the "Hello World!" String constant  
        mv.visitLdcInsn("this is a modify method!");
        // invokes the 'println' method (defined in the PrintStream class)  
        mv.visitMethodInsn(INVOKEVIRTUAL,
                           "java/io/PrintStream",
                           "println",
                           "(Ljava/lang/String;)V");
        //                mv.visitInsn(RETURN);
    }
    super.visitInsn(opcode);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:18,代码来源:AsmExample.java

示例6: asmMethodReturn

/**
 * 组装被拦截方法正常返回时的拦截动作
 */
@SuppressWarnings("unchecked")
private static void asmMethodReturn(MethodModifierContext context) {
    InsnList il = context.mn.instructions;

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

        switch (abstractInsnNode.getOpcode()) {
            case Opcodes.RETURN:
                il.insertBefore(abstractInsnNode, createVoidReturnInstructions(context));
                break;
            case Opcodes.IRETURN:
            case Opcodes.LRETURN:
            case Opcodes.FRETURN:
            case Opcodes.ARETURN:
            case Opcodes.DRETURN:
                il.insertBefore(abstractInsnNode, createReturnInstructions(context));
        }
    }
}
 
开发者ID:yutian-tianpl,项目名称:byte-cobweb,代码行数:24,代码来源:MethodModifier.java

示例7: hookMethod

/**
 * (none-javadoc)
 *
 * @see com.fuxi.javaagent.hook.AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor)
 */
@Override
protected MethodVisitor hookMethod(int access, String name, String desc, String signature, String[] exceptions, MethodVisitor mv) {
    // store file info in lockClose Object
    if ("<init>".equals(name) && "(Ljava/io/File;Z)V".equals(desc)) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            public void onMethodExit(int opcode) {
                if (opcode == Opcodes.RETURN) {
                    mv.visitVarInsn(ALOAD, 0);
                    mv.visitTypeInsn(NEW, "com/fuxi/javaagent/tool/hook/CustomLockObject");
                    mv.visitInsn(DUP);
                    mv.visitMethodInsn(INVOKESPECIAL, "com/fuxi/javaagent/tool/hook/CustomLockObject",
                            "<init>", "()V", false);
                    mv.visitFieldInsn(PUTFIELD, "java/io/FileOutputStream", "closeLock", "Ljava/lang/Object;");
                    mv.visitVarInsn(ALOAD, 0);
                    mv.visitFieldInsn(GETFIELD, "java/io/FileOutputStream", "closeLock", "Ljava/lang/Object;");
                    mv.visitVarInsn(ALOAD, 3);
                    mv.visitMethodInsn(INVOKESTATIC, "com/fuxi/javaagent/hook/file/FileOutputStream2Hook", "checkFileOutputStreamInit",
                            "(Ljava/lang/Object;Ljava/lang/String;)V", false);
                }
                super.onMethodExit(opcode);
            }
        };
    }
    if (name.equals("write") && desc.startsWith("([B")) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            public void onMethodEnter() {
                mv.visitVarInsn(ALOAD, 0);
                mv.visitFieldInsn(GETFIELD, "java/io/FileOutputStream", "closeLock", "Ljava/lang/Object;");
                mv.visitVarInsn(ALOAD, 1);
                mv.visitMethodInsn(INVOKESTATIC, "com/fuxi/javaagent/hook/file/FileOutputStream2Hook", "checkFileOutputStreamWrite",
                        "(Ljava/lang/Object;[B)V", false);
            }
        };
    }
    return mv;
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:43,代码来源:FileOutputStream2Hook.java

示例8: transformClassInit

/**
 * Transforms an existin &lt;clinit> method. Adds bytecode before the return, if
 * exists.
 * @param className
 * @param target 
 */
private void transformClassInit(String className, MethodNode target) {
    Type classType = Type.getObjectType(className);
    if (target.instructions.size() > 0) {
        if (target.instructions.getLast().getOpcode() == Opcodes.RETURN) {
            target.instructions.remove(target.instructions.getLast());
        }
    }
    // ldc
    target.visitLdcInsn(classType);
    // invokevirtual --> classloader on stack
    target.visitMethodInsn(
            Opcodes.INVOKEVIRTUAL,
            JAVA_LANG_CLASS,
            CLASS_GET_CLASSLODER_METHOD,
            CLASS_GET_CLASSLOADER_DESC,
            false
    );
    // putstatic
    target.visitFieldInsn(
            Opcodes.PUTSTATIC,
            AGENT_CLASS,
            AGENT_CLASSLOADER_FIELD,
            AGENT_CLASSLOADER_DESC
    );
    target.visitInsn(Opcodes.RETURN);
    // ldc || classloader instance
    target.maxStack = Math.max(target.maxStack, 1);
    target.maxLocals = Math.max(target.maxLocals, 1);
    target.visitEnd();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:NbJShellAgent.java

示例9: visitInsn

@Override
public void visitInsn(final int opcode) {
    if (mv != null) {
        mv.visitInsn(opcode);
    }
    execute(opcode, 0, null);
    if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)
            || opcode == Opcodes.ATHROW) {
        this.locals = null;
        this.stack = null;
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:12,代码来源:AnalyzerAdapter.java

示例10: visitInsn

@Override
public void visitInsn(int opcode) {
  if(opcode == Opcodes.RETURN) {
    // Load this.
    super.visitVarInsn(Opcodes.ALOAD, 0);

    // Execute drill init.
    super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, SignatureHolder.DRILL_INIT_METHOD, "()V", false);
  }
  super.visitInsn(opcode);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:DrillInitMethodVisitor.java

示例11: visitCode

@Override
public void visitCode() {
	/*
	 * 0  invokestatic mcheli.multiplay.MCH_MultiplayClient.startSendImageData() : void [15]
	 * 3  return
	 */
	super.visitMethodInsn(Opcodes.INVOKESTATIC, "net/teamfruit/mchelishield/MCH_MultiplayClient", "startSendImageData", DescHelper.toDesc(void.class, new Object[0]), false);
	super.visitInsn(Opcodes.RETURN);
}
 
开发者ID:Team-Fruit,项目名称:McHeliPrivacyShield,代码行数:9,代码来源:MCH_MultiplayClientVisitor.java

示例12: append

private void append() {
    if (!this.resultNode.desc.endsWith("V"))
        throw new RuntimeException("Can't append to non-void method!");

    InsnList list = resultNode.instructions;

    AbstractInsnNode node = list.getLast();

    if (node instanceof LabelNode) {
        node = node.getPrevious();
    }

    if (!(node.getOpcode() == Opcodes.RETURN))
        throw new RuntimeException("Method " + this.resultNode.name + " in " + this.owner + " doesn't end with return opcode?!");

    list.remove(node);

    list.add(transformerNode.instructions);

    resultNode.instructions.add(transformerNode.instructions);
}
 
开发者ID:Yamakaja,项目名称:RuntimeTransformer,代码行数:21,代码来源:MethodJob.java

示例13: isReturn

private static boolean isReturn(AbstractInsnNode insn) {
  return Opcodes.IRETURN <= insn.getOpcode() && insn.getOpcode() <= Opcodes.RETURN;
}
 
开发者ID:inferjay,项目名称:r8,代码行数:3,代码来源:JarSourceCode.java


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