Examples of CodeVisitor


Examples of org.objectweb.asm.CodeVisitor

        mv.visitLabel(l6);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoIsNewMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoIsNew", "()Z", null, null);

        generateReturnFalseIfNotIsActive(mv);

        //StateItf sa = speedoGetState();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKEVIRTUAL, classToWrite, M_SPEEDO_GET_STATE, "()" + JT_STATE);
        mv.visitVarInsn(ASTORE, 1);

        //return sa != null && LifeCycle.isNew(sa.jdoGetStatus());
        Label l4 = new Label();
        mv.visitVarInsn(ALOAD, 1);
        mv.visitJumpInsn(IFNULL, l4);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, JCN_STATE, M_SPEEDO_GET_STATUS, "()B");
        mv.visitMethodInsn(INVOKESTATIC,JCN_LIFE_CYCLE, "isNew", "(B)Z");
        mv.visitJumpInsn(IFEQ, l4);
        mv.visitInsn(ICONST_1);
        Label l5 = new Label();
        mv.visitJumpInsn(GOTO, l5);

        mv.visitLabel(l4);
        mv.visitInsn(ICONST_0);
       
        mv.visitLabel(l5);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

        mv.visitLabel(l5);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoIsDeletedMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoIsDeleted", "()Z", null, null);

        generateReturnFalseIfNotIsActive(mv);

        //StateItf sa = speedoGetState();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKEVIRTUAL, classToWrite, M_SPEEDO_GET_STATE, "()" + JT_STATE);
        mv.visitVarInsn(ASTORE, 1);

        //return sa != null && LifeCycle.isDeleted(sa.jdoGetStatus());
        Label l4 = new Label();
        mv.visitVarInsn(ALOAD, 1);
        mv.visitJumpInsn(IFNULL, l4);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, JCN_STATE, M_SPEEDO_GET_STATUS, "()B");
        mv.visitMethodInsn(INVOKESTATIC, JCN_LIFE_CYCLE, "isDeleted", "(B)Z");
        mv.visitJumpInsn(IFEQ, l4);
        mv.visitInsn(ICONST_1);
        Label l5 = new Label();
        mv.visitJumpInsn(GOTO, l5);
       
        mv.visitLabel(l4);
        mv.visitInsn(ICONST_0);
       
        mv.visitLabel(l5);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

        mv.visitLabel(l5);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoIsDetachedMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoIsDetached", "()Z", null, null);
        mv.visitInsn(ICONST_0);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

        mv.visitInsn(ICONST_0);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoReplaceObjectIdMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoReplaceObjectId", "(Ljava/lang/Object;)V", null, null);
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

        mv = cv.visitMethod(ACC_PUBLIC, "jdoReplaceObjectId", "(Ljava/lang/Object;)V", null, null);
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoReplaceStateManagerMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoReplaceStateManager", "(Ljavax/jdo/spi/StateManager;)V", null, null);
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

  public CodeVisitor visitMethod(final int access,
                   final String name,
                   final String desc,
                   final String[] exceptions,
                   final Attribute attrs) {
    CodeVisitor c = cv.visitMethod(access, name, desc, exceptions, attrs);
    if (name.equals("<clinit>")) {
      clinitfound = true;
      addClassRegistrationCode(c);
    } else if (name.equals(CLASS_METH)) {
      classMethodfound = true;
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

  public void visitEnd() {
        if (generationAllowed) {
        if (!clinitfound) {
          logger.log(BasicLevel.DEBUG, "Adding static area in " + classToWrite);
          CodeVisitor c = cv.visitMethod(Constants.ACC_STATIC,
            "<clinit>", "()V", null, null);
          addClassRegistrationCode(c);
          c.visitInsn(RETURN);
          c.visitMaxs(0, 0);
                clinitfound = true;
        }
   
        if (!classMethodfound) {
                classMethodfound = true;
          logger.log(BasicLevel.DEBUG, "Adding static method class$(String)Class in " + classToWrite);
          CodeVisitor c = cv.visitMethod(ACC_STATIC + ACC_SYNTHETIC, CLASS_METH,
            "(Ljava/lang/String;)Ljava/lang/Class;", null, null);
          //try {
                final Label l0 = new Label();
          c.visitLabel(l0);
          //return Class.forName(str)
                c.visitVarInsn(ALOAD, 0);
          c.visitMethodInsn(INVOKESTATIC, "java/lang/Class", "forName",
            "(Ljava/lang/String;)Ljava/lang/Class;");
          final Label l1 = new Label();
          c.visitLabel(l1);
          c.visitInsn(ARETURN);
                final Label l2 = new Label();
          c.visitLabel(l2);
          c.visitVarInsn(ASTORE, 1);
          c.visitTypeInsn(NEW, "java/lang/NoClassDefFoundError");
          c.visitInsn(DUP);
          c.visitVarInsn(ALOAD, 1);
          c.visitMethodInsn(INVOKEVIRTUAL, "java/lang/ClassNotFoundException",
            "getMessage", "()Ljava/lang/String;");
          c.visitMethodInsn(INVOKESPECIAL, "java/lang/NoClassDefFoundError",
            "<init>", "(Ljava/lang/String;)V");
          c.visitInsn(ATHROW);
          c.visitTryCatchBlock(l0, l1, l2, "java/lang/ClassNotFoundException");
          c.visitMaxs(0, 0);
        }
        if (!classFieldfound) {
                classFieldfound = true;
          logger.log(BasicLevel.DEBUG, "Adding static field '"
                        + fieldName + " in " + classToWrite);
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

        } else if (name.equals("this")) {
            // do not merge this method
            return null;
        }
        //Modifies instructions that reference the old class.
        CodeVisitor mv = cv.visitMethod(access, mn, desc, exceptions, attrs);
        if (mv != null) {
            mv = new CodeRenamer(mv, oldClass, classToWrite);
        }
        return mv;
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

    }

    public void visitEnd() {
        // Merge the static initializer
        if (methodNames.size() > 0) {
            CodeVisitor mv = this.cv.visitMethod(Constants.ACC_STATIC,
                    "<clinit>", "()V", null, null);
            for (int i = 0; i < methodNames.size(); i++) {
                String methodName = (String) methodNames.get(i);
                mv.visitMethodInsn(Constants.INVOKESTATIC, classToWrite,
                        methodName, "()V");
            }
            mv.visitInsn(Constants.RETURN);
        }
        super.visitEnd();
    }
View Full Code Here

Examples of org.objectweb.asm.CodeVisitor

     */
    private void generateGetCeObjectMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: getCeObject");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "getCeObject",
                "()Ljava/lang/Object;", null, null);
        // return this;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitInsn(ARETURN);
        mv.visitMaxs(0, 0);
    }
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.