Example usage for org.objectweb.asm Opcodes RETURN

List of usage examples for org.objectweb.asm Opcodes RETURN

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes RETURN.

Prototype

int RETURN

To view the source code for org.objectweb.asm Opcodes RETURN.

Click Source Link

Usage

From source file:appeng.transformer.asm.ASMTweaker.java

License:Open Source License

@Nullable
@Override/*  w  w  w. j  av  a2  s  . c o m*/
public byte[] transform(String name, String transformedName, byte[] basicClass) {
    if (basicClass == null) {
        return null;
    }

    try {
        if (transformedName != null && this.privateToPublicMethods.containsKey(transformedName)) {
            ClassNode classNode = new ClassNode();
            ClassReader classReader = new ClassReader(basicClass);
            classReader.accept(classNode, 0);

            for (PublicLine set : this.privateToPublicMethods.get(transformedName)) {
                this.makePublic(classNode, set);
            }

            // CALL VIRTUAL!
            if (transformedName.equals("net.minecraft.client.gui.inventory.GuiContainer")) {
                for (MethodNode mn : classNode.methods) {
                    if (mn.name.equals("func_146977_a") || (mn.name.equals("a") && mn.desc.equals("(Lzk;)V"))) {
                        MethodNode newNode = new MethodNode(Opcodes.ACC_PUBLIC, "func_146977_a_original",
                                mn.desc, mn.signature, EXCEPTIONS);
                        newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
                        newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
                        newNode.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.name,
                                mn.name, mn.desc, false));
                        newNode.instructions.add(new InsnNode(Opcodes.RETURN));
                        this.log(newNode.name + newNode.desc + " - New Method");
                        classNode.methods.add(newNode);
                        break;
                    }
                }

                for (MethodNode mn : classNode.methods) {
                    if (mn.name.equals("func_73863_a") || mn.name.equals("drawScreen")
                            || (mn.name.equals("a") && mn.desc.equals("(IIF)V"))) {
                        Iterator<AbstractInsnNode> i = mn.instructions.iterator();
                        while (i.hasNext()) {
                            AbstractInsnNode in = i.next();
                            if (in.getOpcode() == Opcodes.INVOKESPECIAL) {
                                MethodInsnNode n = (MethodInsnNode) in;
                                if (n.name.equals("func_146977_a")
                                        || (n.name.equals("a") && n.desc.equals("(Lzk;)V"))) {
                                    this.log(n.name + n.desc + " - Invoke Virtual");
                                    mn.instructions.insertBefore(n, new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
                                            n.owner, n.name, n.desc, false));
                                    mn.instructions.remove(in);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
            classNode.accept(writer);
            return writer.toByteArray();
        }
    } catch (Throwable ignored) {
    }

    return basicClass;
}

From source file:asmlib.Type.java

License:Open Source License

/** Mtodo que retorna o opcode certo para o tipo de varivel que se quer fazer return.
  * Opcodes disponveis:/*from   w  w  w .  java  2s .  c o m*/
  * - IRETURN para boolean, byte, char, short, int
  * - LRETURN para long
  * - FRETURN para float
  * - DRETURN para double
  * - ARETURN para referncia (objecto ou array)
  * -  RETURN para mtodos void
  **/
public int getReturnInsn() {
    char c = bytecodeName().charAt(0);
    switch (c) {
    case 'Z': // boolean
    case 'B': // byte
    case 'C': // char
    case 'S': // short
    case 'I': // int
        return Opcodes.IRETURN;
    case 'J': // long
        return Opcodes.LRETURN;
    case 'F': // float
        return Opcodes.FRETURN;
    case 'D': // double
        return Opcodes.DRETURN;
    case '[': // Algum tipo de array
    case 'L': // objecto
    case 'T': // objecto (generics)
        return Opcodes.ARETURN;
    case 'V': // void
        return Opcodes.RETURN;
    }
    throw new InstrumentationException("Unknown fieldType in getReturnInsn");
}

From source file:ataspectj.UnweavableTest.java

License:Open Source License

ISome getJit() {
    ClassWriter cw = new ClassWriter(true, true);
    cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "ataspectj/ISomeGen", null, "java/lang/Object",
            new String[] { "ataspectj/UnweavableTest$ISome" });
    AnnotationVisitor av = cw.visitAnnotation("Lataspectj/UnweavableTest$ASome;", true);
    av.visitEnd();//  w  w  w . j  a v  a 2 s  .  c o m

    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[0]);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "giveOne", "()I", null, new String[0]);
    mv.visitInsn(Opcodes.ICONST_2);
    mv.visitInsn(Opcodes.IRETURN);
    mv.visitMaxs(0, 0);
    cw.visitEnd();

    try {
        ClassLoader loader = this.getClass().getClassLoader();
        Method def = ClassLoader.class.getDeclaredMethod("defineClass",
                new Class[] { String.class, byte[].class, int.class, int.class });
        def.setAccessible(true);
        Class gen = (Class) def.invoke(loader, "ataspectj.ISomeGen", cw.toByteArray(), 0,
                cw.toByteArray().length);
        return (ISome) gen.newInstance();
    } catch (Throwable t) {
        fail(t.toString());
        return null;
    }
}

From source file:ataspectj.UnweavableTest.java

License:Open Source License

Serializable getJitNoMatch() {
    ClassWriter cw = new ClassWriter(true, true);
    cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "ataspectj/unmatched/Gen", null, "java/lang/Object",
            new String[] { "java/io/Serializable" });

    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[0]);
    mv.visitVarInsn(Opcodes.ALOAD, 0);//  w  ww  . j a v a 2  s  . c  o  m
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    cw.visitEnd();

    try {
        ClassLoader loader = this.getClass().getClassLoader();
        Method def = ClassLoader.class.getDeclaredMethod("defineClass",
                new Class[] { String.class, byte[].class, int.class, int.class });
        def.setAccessible(true);
        Class gen = (Class) def.invoke(loader, "ataspectj.unmatched.Gen", cw.toByteArray(), 0,
                cw.toByteArray().length);
        return (Serializable) gen.newInstance();
    } catch (Throwable t) {
        fail(t.toString());
        return null;
    }
}

From source file:blusunrize.immersiveengineering.common.util.compat.jei.arcfurnace.ArcFurnaceRecipeWrapper.java

private static Class<? extends ArcFurnaceRecipeWrapper> createSubWrapper(String subtype) throws Exception {
    String entitySuperClassName = Type.getInternalName(ArcFurnaceRecipeWrapper.class);
    String entityProxySubClassName = ArcFurnaceRecipeWrapper.class.getSimpleName().concat(subtype);
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, entityProxySubClassName, null,
            entitySuperClassName, null);
    cw.visitSource(entityProxySubClassName.concat(".java"), null);
    //create constructor
    String methodDescriptor = "(L" + Type.getInternalName(ArcFurnaceRecipe.class) + ";)V";
    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", methodDescriptor, null, null);
    mv.visitCode();// w  w  w . j  a v  a2s .c om
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitVarInsn(Opcodes.ALOAD, 1);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, entitySuperClassName, "<init>", methodDescriptor, false);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    cw.visitEnd();
    return (Class<? extends ArcFurnaceRecipeWrapper>) new ProxyClassLoader(
            Thread.currentThread().getContextClassLoader(), cw.toByteArray())
                    .loadClass(entityProxySubClassName.replaceAll("/", "."));
}

From source file:br.usp.each.saeg.badua.core.internal.instr.CoverageMethodTransformer.java

License:Open Source License

private boolean isReturn(final int opcode) {
    if (opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)
        return true;

    return opcode == Opcodes.ATHROW;
}

From source file:bytecode.InstructionExporter.java

License:Apache License

/**
 * Outputs a void return instruction./*www.  ja v  a  2 s  . c  o  m*/
 *
 * @param instruction Void return instruction.
 * @return            <code>null</code>
 */
@Override
public Void visit(Return instruction) {
    mv.visitInsn(Opcodes.RETURN);
    return null;
}

From source file:bytecode.MethodImporter.java

License:Apache License

/**
 * Imports instructions with no immediate operands.
 *
 * @param opcode Opcode.//ww w.j a  va 2  s .c  om
 */
@Override
public void visitInsn(final int opcode) {
    Producer a, b, c, d;
    Type top;

    switch (opcode) {
    // Constants
    case Opcodes.ACONST_NULL:
        createConstant(null);
        break;
    case Opcodes.ICONST_M1:
        createConstant(new Integer(-1));
        break;
    case Opcodes.ICONST_0:
        createConstant(new Integer(0));
        break;
    case Opcodes.ICONST_1:
        createConstant(new Integer(1));
        break;
    case Opcodes.ICONST_2:
        createConstant(new Integer(2));
        break;
    case Opcodes.ICONST_3:
        createConstant(new Integer(3));
        break;
    case Opcodes.ICONST_4:
        createConstant(new Integer(4));
        break;
    case Opcodes.ICONST_5:
        createConstant(new Integer(5));
        break;
    case Opcodes.LCONST_0:
        createConstant(new Long(0));
        break;
    case Opcodes.LCONST_1:
        createConstant(new Long(1));
        break;
    case Opcodes.FCONST_0:
        createConstant(new Float(0.0f));
        break;
    case Opcodes.FCONST_1:
        createConstant(new Float(1.0f));
        break;
    case Opcodes.FCONST_2:
        createConstant(new Float(2.0f));
        break;
    case Opcodes.DCONST_0:
        createConstant(new Double(0.0f));
        break;
    case Opcodes.DCONST_1:
        createConstant(new Double(1.0f));
        break;

    // Binary Operations
    case Opcodes.IADD:
        createArithmetic(Arithmetic.Operator.ADD, Type.INT);
        break;
    case Opcodes.LADD:
        createArithmetic(Arithmetic.Operator.ADD, Type.LONG);
        break;
    case Opcodes.FADD:
        createArithmetic(Arithmetic.Operator.ADD, Type.FLOAT);
        break;
    case Opcodes.DADD:
        createArithmetic(Arithmetic.Operator.ADD, Type.DOUBLE);
        break;
    case Opcodes.ISUB:
        createArithmetic(Arithmetic.Operator.SUB, Type.INT);
        break;
    case Opcodes.LSUB:
        createArithmetic(Arithmetic.Operator.SUB, Type.LONG);
        break;
    case Opcodes.FSUB:
        createArithmetic(Arithmetic.Operator.SUB, Type.FLOAT);
        break;
    case Opcodes.DSUB:
        createArithmetic(Arithmetic.Operator.SUB, Type.DOUBLE);
        break;
    case Opcodes.IMUL:
        createArithmetic(Arithmetic.Operator.MUL, Type.INT);
        break;
    case Opcodes.LMUL:
        createArithmetic(Arithmetic.Operator.MUL, Type.LONG);
        break;
    case Opcodes.FMUL:
        createArithmetic(Arithmetic.Operator.MUL, Type.FLOAT);
        break;
    case Opcodes.DMUL:
        createArithmetic(Arithmetic.Operator.MUL, Type.DOUBLE);
        break;
    case Opcodes.IDIV:
        createArithmetic(Arithmetic.Operator.DIV, Type.INT);
        break;
    case Opcodes.LDIV:
        createArithmetic(Arithmetic.Operator.DIV, Type.LONG);
        break;
    case Opcodes.FDIV:
        createArithmetic(Arithmetic.Operator.DIV, Type.FLOAT);
        break;
    case Opcodes.DDIV:
        createArithmetic(Arithmetic.Operator.DIV, Type.DOUBLE);
        break;
    case Opcodes.IREM:
        createArithmetic(Arithmetic.Operator.REM, Type.INT);
        break;
    case Opcodes.LREM:
        createArithmetic(Arithmetic.Operator.REM, Type.LONG);
        break;
    case Opcodes.FREM:
        createArithmetic(Arithmetic.Operator.REM, Type.FLOAT);
        break;
    case Opcodes.DREM:
        createArithmetic(Arithmetic.Operator.REM, Type.DOUBLE);
        break;
    case Opcodes.IAND:
        createArithmetic(Arithmetic.Operator.AND, Type.INT);
        break;
    case Opcodes.LAND:
        createArithmetic(Arithmetic.Operator.AND, Type.LONG);
        break;
    case Opcodes.IOR:
        createArithmetic(Arithmetic.Operator.OR, Type.INT);
        break;
    case Opcodes.LOR:
        createArithmetic(Arithmetic.Operator.OR, Type.LONG);
        break;
    case Opcodes.IXOR:
        createArithmetic(Arithmetic.Operator.XOR, Type.INT);
        break;
    case Opcodes.LXOR:
        createArithmetic(Arithmetic.Operator.XOR, Type.LONG);
        break;
    case Opcodes.ISHL:
        createArithmetic(Arithmetic.Operator.SHL, Type.INT);
        break;
    case Opcodes.LSHL:
        createArithmetic(Arithmetic.Operator.SHL, Type.LONG);
        break;
    case Opcodes.ISHR:
        createArithmetic(Arithmetic.Operator.SHR, Type.INT);
        break;
    case Opcodes.LSHR:
        createArithmetic(Arithmetic.Operator.SHR, Type.LONG);
        break;
    case Opcodes.IUSHR:
        createArithmetic(Arithmetic.Operator.USHR, Type.INT);
        break;
    case Opcodes.LUSHR:
        createArithmetic(Arithmetic.Operator.USHR, Type.LONG);
        break;

    case Opcodes.LCMP:
        createCompare(false, Type.LONG);
        break;
    case Opcodes.FCMPL:
        createCompare(false, Type.FLOAT);
        break;
    case Opcodes.FCMPG:
        createCompare(true, Type.FLOAT);
        break;
    case Opcodes.DCMPL:
        createCompare(false, Type.DOUBLE);
        break;
    case Opcodes.DCMPG:
        createCompare(true, Type.DOUBLE);
        break;
    case Opcodes.INEG:
        createNegate();
        break;
    case Opcodes.LNEG:
        createNegate();
        break;
    case Opcodes.FNEG:
        createNegate();
        break;
    case Opcodes.DNEG:
        createNegate();
        break;
    case Opcodes.I2L:
        createConvert(Type.LONG);
        break;
    case Opcodes.I2F:
        createConvert(Type.FLOAT);
        break;
    case Opcodes.I2D:
        createConvert(Type.DOUBLE);
        break;
    case Opcodes.I2B:
        createConvert(Type.BYTE);
        break;
    case Opcodes.I2C:
        createConvert(Type.CHAR);
        break;
    case Opcodes.I2S:
        createConvert(Type.SHORT);
        break;
    case Opcodes.L2I:
        createConvert(Type.INT);
        break;
    case Opcodes.L2F:
        createConvert(Type.FLOAT);
        break;
    case Opcodes.L2D:
        createConvert(Type.DOUBLE);
        break;
    case Opcodes.F2I:
        createConvert(Type.INT);
        break;
    case Opcodes.F2L:
        createConvert(Type.LONG);
        break;
    case Opcodes.F2D:
        createConvert(Type.DOUBLE);
        break;
    case Opcodes.D2I:
        createConvert(Type.INT);
        break;
    case Opcodes.D2F:
        createConvert(Type.FLOAT);
        break;
    case Opcodes.D2L:
        createConvert(Type.LONG);
        break;
    case Opcodes.IALOAD:
        createArrayRead(Type.INT);
        break;
    case Opcodes.LALOAD:
        createArrayRead(Type.LONG);
        break;
    case Opcodes.FALOAD:
        createArrayRead(Type.FLOAT);
        break;
    case Opcodes.DALOAD:
        createArrayRead(Type.DOUBLE);
        break;
    case Opcodes.AALOAD:
        createArrayRead(Type.getFreshRef());
        break;
    case Opcodes.BALOAD:
        createArrayRead(Type.BYTE);
        break;
    case Opcodes.CALOAD:
        createArrayRead(Type.CHAR);
        break;
    case Opcodes.SALOAD:
        createArrayRead(Type.SHORT);
        break;
    case Opcodes.IASTORE:
        createArrayWrite(Type.INT);
        break;
    case Opcodes.LASTORE:
        createArrayWrite(Type.LONG);
        break;
    case Opcodes.FASTORE:
        createArrayWrite(Type.FLOAT);
        break;
    case Opcodes.DASTORE:
        createArrayWrite(Type.DOUBLE);
        break;
    case Opcodes.AASTORE:
        createArrayWrite(Type.getFreshRef());
        break;
    case Opcodes.BASTORE:
        createArrayWrite(Type.BYTE);
        break;
    case Opcodes.CASTORE:
        createArrayWrite(Type.CHAR);
        break;
    case Opcodes.SASTORE:
        createArrayWrite(Type.SHORT);
        break;
    case Opcodes.IRETURN:
        createReturn(Type.INT);
        break;
    case Opcodes.LRETURN:
        createReturn(Type.LONG);
        break;
    case Opcodes.FRETURN:
        createReturn(Type.FLOAT);
        break;
    case Opcodes.DRETURN:
        createReturn(Type.DOUBLE);
        break;
    case Opcodes.ARETURN:
        createReturn(Type.REF);
        break;
    case Opcodes.RETURN:
        createReturn(null);
        break;
    case Opcodes.ATHROW:
        createThrow();
        break;

    // Array Length
    case Opcodes.ARRAYLENGTH:
        ordered.add(stack.push(new ArrayLength(stack.pop())));
        break;

    // Swap
    case Opcodes.SWAP:
        a = stack.pop();
        b = stack.pop();

        stack.push(a);
        stack.push(b);

        ordered.add(new StackOperation(StackOperation.Sort.SWAP));

        break;

    // Duplicates
    case Opcodes.DUP:
        stack.push(stack.peek());
        ordered.add(new StackOperation(StackOperation.Sort.DUP));
        break;
    case Opcodes.DUP2:
        top = stack.peek().getType();

        // Type 2 Values
        if (top.getSize() == 2) {
            stack.push(stack.peek());
            // Type 1 Values
        } else {
            b = stack.pop();
            a = stack.pop();

            stack.push(a);
            stack.push(b);
            stack.push(a);
            stack.push(b);
        }

        ordered.add(new StackOperation(StackOperation.Sort.DUP2));

        break;
    case Opcodes.DUP_X1:
        b = stack.pop();
        a = stack.pop();

        stack.push(b);
        stack.push(a);
        stack.push(b);

        ordered.add(new StackOperation(StackOperation.Sort.DUP_X1));

        break;
    case Opcodes.DUP_X2:
        top = stack.peek().getType();

        // Type 2 Values
        if (top.getSize() == 2) {
            b = stack.pop();
            a = stack.pop();

            stack.push(b);
            stack.push(a);
            stack.push(b);
            // Type 1 Values
        } else {
            c = stack.pop();
            b = stack.pop();
            a = stack.pop();

            stack.push(c);
            stack.push(a);
            stack.push(b);
            stack.push(c);
        }

        ordered.add(new StackOperation(StackOperation.Sort.DUP_X2));

        break;

    // Pops
    case Opcodes.POP:
        stack.pop();
        ordered.add(new StackOperation(StackOperation.Sort.POP));
        break;
    case Opcodes.POP2:
        top = stack.peek().getType();

        // Type 2 Values
        if (top.getSize() == 2) {
            stack.pop();
            // Type 1 Values
        } else {
            stack.pop();
            stack.pop();
        }

        ordered.add(new StackOperation(StackOperation.Sort.POP2));

        break;

    // TODO: DUP2_X1, DUP2_X2, MONITORENTER, MONITOREXIT
    case Opcodes.MONITORENTER:
        throw new RuntimeException("visitInsn: MONITORENTER");
    case Opcodes.MONITOREXIT:
        throw new RuntimeException("visitInsn: MONITOREXIT");
    case Opcodes.DUP2_X1:
        throw new RuntimeException("visitInsn: DUP2_X1");
    case Opcodes.DUP2_X2:
        throw new RuntimeException("visitInsn: DUP2_X2");
    default:
        throw new RuntimeException("visitInsn: " + opcode);
    }
}

From source file:ch.eiafr.cojac.Agent.java

License:Apache License

/**
* This method works only with the FloatReplacerClasses class
* It instruments it to create a static initializer block to set
* all the static variables used by the agent and injected in the 
* instrumented application.//from  w  ww .ja va2  s . c  o  m
* Warning: this is not the only place to set these variables, see class
* "CojacReferences" !
* This is used when there is more than one classloader in the application
*/
private byte[] setGlobalFields(byte[] byteCode, ClassLoader loader) {
    ClassReader cr = new ClassReader(byteCode);
    ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
        @Override
        public void visit(int version, int access, String name, String signature, String superName,
                String[] interfaces) {
            super.visit(version, access, name, signature, superName, interfaces);
            MethodVisitor mv = cv.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
            mv.visitLdcInsn(references.getDoubleWrapper());
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setNgWrapper", "(Ljava/lang/String;)V", false);
            mv.visitLdcInsn(references.getNgWrapper());
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setDoubleWrapper", "(Ljava/lang/String;)V", false);
            mv.visitLdcInsn(references.getFloatWrapper());
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setFloatWrapper", "(Ljava/lang/String;)V", false);
            mv.visitLdcInsn(references.getBigDecimalPrecision());
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setBigDecimalPrecision", "(I)V", false);
            mv.visitLdcInsn(references.getStabilityThreshold());
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setStabilityThreshold", "(D)V", false);
            mv.visitLdcInsn(references.getCheckUnstableComparisons() ? 1 : 0);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, name, "setCheckUnstableComparisons", "(Z)V", false);
            mv.visitInsn(Opcodes.RETURN);
            mv.visitMaxs(0, 0);
        }
    };
    cr.accept(cv, ClassReader.EXPAND_FRAMES);
    return cw.toByteArray();
}

From source file:Client.JClassPatcher.java

License:Open Source License

private void patchMenu(ClassNode node) {
    Logger.Info("Patching menu (" + node.name + ".class)");

    Iterator<MethodNode> methodNodeList = node.methods.iterator();
    while (methodNodeList.hasNext()) {
        MethodNode methodNode = methodNodeList.next();

        // Menu swap hook
        if (methodNode.name.equals("e") && methodNode.desc.equals("(II)V")) {
            AbstractInsnNode first = methodNode.instructions.getFirst();

            LabelNode label = new LabelNode();
            methodNode.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 0));
            methodNode.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Menu",
                    "switchList", "(Ljava/lang/Object;)Z"));
            methodNode.instructions.insertBefore(first, new JumpInsnNode(Opcodes.IFGT, label));
            methodNode.instructions.insertBefore(first, new InsnNode(Opcodes.RETURN));
            methodNode.instructions.insertBefore(first, label);
        }//from  w w  w  . ja va  2  s . c  o  m
    }
}