Examples of addInvokevirtual()


Examples of javassist.bytecode.Bytecode.addInvokevirtual()

public class PrintLn {
    public static Bytecode println(ConstPool cp, String message) {
        Bytecode proxyBytecode = new Bytecode(cp);
        proxyBytecode.addGetstatic("java/lang/System", "out", "Ljava/io/PrintStream;");
        proxyBytecode.addLdc(message);
        proxyBytecode.addInvokevirtual("java.io.PrintStream", "println", "(Ljava/lang/String;)V");
        return proxyBytecode;
    }

    public static void println(Bytecode proxyBytecode, String message) {
        proxyBytecode.addGetstatic("java/lang/System", "out", "Ljava/io/PrintStream;");
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

                        ManipulationUtils.add16bit(cd, run.getSize() + 3);

                        Bytecode b = new Bytecode(file.getConstPool());
                        // this.getClass()
                        b.add(Opcode.ALOAD_0);
                        b.addInvokevirtual("java.lang.Object", "getClass", "()Ljava/lang/Class;");
                        b.addInvokevirtual("java.lang.Class", "getName", "()Ljava/lang/String;");
                        // now we have the class name on the stack
                        // push the class being manipulateds name onto the stack
                        b.addLdc(file.getName());
                        b.addInvokevirtual("java.lang.Object", "equals", "(Ljava/lang/Object;)Z");
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

                        Bytecode b = new Bytecode(file.getConstPool());
                        // this.getClass()
                        b.add(Opcode.ALOAD_0);
                        b.addInvokevirtual("java.lang.Object", "getClass", "()Ljava/lang/Class;");
                        b.addInvokevirtual("java.lang.Class", "getName", "()Ljava/lang/String;");
                        // now we have the class name on the stack
                        // push the class being manipulateds name onto the stack
                        b.addLdc(file.getName());
                        b.addInvokevirtual("java.lang.Object", "equals", "(Ljava/lang/Object;)Z");
                        // now we have a boolean on top of the stack
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

                        b.addInvokevirtual("java.lang.Object", "getClass", "()Ljava/lang/Class;");
                        b.addInvokevirtual("java.lang.Class", "getName", "()Ljava/lang/String;");
                        // now we have the class name on the stack
                        // push the class being manipulateds name onto the stack
                        b.addLdc(file.getName());
                        b.addInvokevirtual("java.lang.Object", "equals", "(Ljava/lang/Object;)Z");
                        // now we have a boolean on top of the stack
                        b.add(Opcode.IFNE); // if true jump
                        ManipulationUtils.add16bit(b, run.getSize() + cd.getSize() + 3);

                        try {
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

                                // now perform the fake call
                                b.addInvokestatic(methodReflectionLocation, "invoke", REPLACED_METHOD_DESCRIPTOR);
                                b.add(Opcode.GOTO);
                                JumpMarker finish = JumpUtils.addJumpInstruction(b);
                                performRealCall.mark();
                                b.addInvokevirtual(Method.class.getName(), METHOD_NAME, METHOD_DESCRIPTOR);
                                finish.mark();
                                it.writeByte(CodeIterator.NOP, index);
                                it.writeByte(CodeIterator.NOP, index + 1);
                                it.writeByte(CodeIterator.NOP, index + 2);
                                it.insertEx(b.get());
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

        if (staticMethod) {
            proxyBytecode.addInvokestatic(className, Constants.ADDED_STATIC_METHOD_NAME, "(I[Ljava/lang/Object;)Ljava/lang/Object;");
        } else if (isInterface) {
            proxyBytecode.addInvokeinterface(className, Constants.ADDED_METHOD_NAME, "(I[Ljava/lang/Object;)Ljava/lang/Object;", 3);
        } else {
            proxyBytecode.addInvokevirtual(className, Constants.ADDED_METHOD_NAME, "(I[Ljava/lang/Object;)Ljava/lang/Object;");
        }
        // cast it to the appropriate type and return it
        ManipulationUtils.MethodReturnRewriter.addReturnProxyMethod(mInfo.getDescriptor(), proxyBytecode);
        CodeAttribute ca = proxyBytecode.toCodeAttribute();
        ca.setMaxLocals(locals);
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

        info.setAccessFlags(AccessFlag.PUBLIC);
        CtClass stringClass = pool.get("java.lang.String");
        Bytecode code = new Bytecode(info.getConstPool(), 2, 9);
        /* 0   */ code.addAload(0);
        /* 1   */ code.addLdc("start");
        /* 3   */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 6   */ code.addAload(0);
        /* 7   */ code.addLdc("try");
        /* 9   */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 12  */ addJump(code, Opcode.GOTO, 125);
        /* 14  */ code.addAstore(2);
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

        /* 0   */ code.addAload(0);
        /* 1   */ code.addLdc("start");
        /* 3   */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 6   */ code.addAload(0);
        /* 7   */ code.addLdc("try");
        /* 9   */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 12  */ addJump(code, Opcode.GOTO, 125);
        /* 14  */ code.addAstore(2);
        /* 16  */ code.addAload(2);
        /* 17  */ code.addInvokevirtual("java.lang.Exception", "printStackTrace", "()V");
        /* 20  */ addJump(code, Opcode.GOTO, 125);
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

        /* 7   */ code.addLdc("try");
        /* 9   */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 12  */ addJump(code, Opcode.GOTO, 125);
        /* 14  */ code.addAstore(2);
        /* 16  */ code.addAload(2);
        /* 17  */ code.addInvokevirtual("java.lang.Exception", "printStackTrace", "()V");
        /* 20  */ addJump(code, Opcode.GOTO, 125);
        /* 23  */ code.addAstore(4);
        /* 25  */ addJump(code, Opcode.JSR, 31);
        /* 28  */ code.addAload(4);
        /* 30  */ code.addOpcode(Opcode.ATHROW);
View Full Code Here

Examples of javassist.bytecode.Bytecode.addInvokevirtual()

                  code.add32bit(2); // 2 pairs
                  code.add32bit(15); code.add32bit(60 - spos);
                  code.add32bit(1789); code.add32bit(117 - spos);
        /* 60  */ code.addAload(0);
        /* 61  */ code.addLdc("inner-try");
        /* 63  */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 66  */ addJump(code, Opcode.GOTO, 111);
        /* 69  */ code.addAstore(6);
        /* 71  */ addJump(code, Opcode.JSR, 77);
        /* 74  */ code.addAload(6);
        /* 76  */ code.add(Opcode.ATHROW);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.