本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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 });
}
}
}
示例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);
}
示例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));
}
}
}
示例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;
}
示例8: transformClassInit
/**
* Transforms an existin <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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例13: isReturn
private static boolean isReturn(AbstractInsnNode insn) {
return Opcodes.IRETURN <= insn.getOpcode() && insn.getOpcode() <= Opcodes.RETURN;
}