Package javassist.bytecode

Examples of javassist.bytecode.Bytecode.addLdc()


                                if (op == Opcode.PUTFIELD) {
                                    Bytecode b = new Bytecode(file.getConstPool());
                                    if (data.getDescriptor().charAt(0) != 'L' && data.getDescriptor().charAt(0) != '[') {
                                        Boxing.box(b, data.getDescriptor().charAt(0));
                                    }
                                    b.addLdc(arrayPos);
                                    b.addInvokestatic(FIELD_DATA_STORE_CLASS, "setValue", "(Ljava/lang/Object;Ljava/lang/Object;I)V");
                                    it.insertEx(b.get());
                                } else if (op == Opcode.GETFIELD) {
                                    Bytecode b = new Bytecode(file.getConstPool());
                                    b.addLdc(arrayPos);
View Full Code Here


                                    b.addLdc(arrayPos);
                                    b.addInvokestatic(FIELD_DATA_STORE_CLASS, "setValue", "(Ljava/lang/Object;Ljava/lang/Object;I)V");
                                    it.insertEx(b.get());
                                } else if (op == Opcode.GETFIELD) {
                                    Bytecode b = new Bytecode(file.getConstPool());
                                    b.addLdc(arrayPos);
                                    b.addInvokestatic(FIELD_DATA_STORE_CLASS, "getValue", "(Ljava/lang/Object;I)Ljava/lang/Object;");

                                    if (DescriptorUtils.isPrimitive(data.getDescriptor())) {
                                        Boxing.unbox(b, data.getDescriptor().charAt(0));
                                    } else {
View Full Code Here

        MethodInfo info = method.getMethodInfo2();
        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);
View Full Code Here

        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);
        /* 16  */ code.addAload(2);
        /* 17  */ code.addInvokevirtual("java.lang.Exception", "printStackTrace", "()V");
View Full Code Here

                  code.add32bit(60 - spos); // default
                  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);
View Full Code Here

        /* 71  */ addJump(code, Opcode.JSR, 77);
        /* 74  */ code.addAload(6);
        /* 76  */ code.add(Opcode.ATHROW);
        /* 77  */ code.addAstore(5);
        /* 79  */ code.addAload(0);
        /* 80  */ code.addLdc("inner-inner-try");
        /* 82  */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 85  */ addJump(code, Opcode.GOTO, 106);
        /* 88  */ code.addAstore(8);
        /* 90  */ addJump(code, Opcode.JSR, 96);
        /* 93  */ code.addAload(8);
View Full Code Here

        /* 90  */ addJump(code, Opcode.JSR, 96);
        /* 93  */ code.addAload(8);
        /* 95  */ code.add(Opcode.ATHROW);
        /* 96  */ code.addAstore(7);
        /* 98  */ code.addAload(0);
        /* 99  */ code.addLdc("inner-finally");
        /* 101 */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 104 */ code.addRet(7);
        /* 106 */ addJump(code, Opcode.JSR, 96);
        /* 109 */ code.addRet(5);
        /* 111 */ addJump(code, Opcode.JSR, 77);
View Full Code Here

        /* 106 */ addJump(code, Opcode.JSR, 96);
        /* 109 */ code.addRet(5);
        /* 111 */ addJump(code, Opcode.JSR, 77);
        /* 114 */ addJump(code, Opcode.GOTO, 123);
        /* 117 */ code.addAload(0);
        /* 118 */ code.addLdc("switch - 1789");
        /* 120 */ code.addInvokevirtual(clazz, "println", CtClass.voidType, new CtClass[] {stringClass});
        /* 123 */ code.addRet(3);
        /* 125 */ addJump(code, Opcode.JSR, 31);
        /* 128 */ code.addOpcode(Opcode.RETURN);
        code.addExceptionHandler(6, 12, 15, "java.lang.RuntimeException");
View Full Code Here

                            GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
                            1);
    // aload_0
    code.addAload(0);
    // ldc // name of the field
    code.addLdc(finfo.getName());
    // *load_1 // each type
    addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
    // invokeinterface // invoke Callback.read*() // each type
    addInvokeFieldHandlerMethod(classfile, code, finfo.getDescriptor(),
                                true);
View Full Code Here

                            GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
                            1);
    // aload_0
    code.addAload(0);
    // ldc // field name
    code.addLdc(finfo.getName());
    // aload_0
    code.addAload(0);
    // getfield // old value of the field
    code.addOpcode(Opcode.GETFIELD);
    code.addIndex(base_field_index);
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.