Package org.objectweb.asm

Examples of org.objectweb.asm.CodeVisitor


        mv.visitLabel(l8);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoIsTransactionalMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoIsTransactional", "()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);

        //if (sa == null) {
        //    return false;
        //}
        mv.visitVarInsn(ALOAD, 1);
        Label l4 = new Label();
        mv.visitJumpInsn(IFNONNULL, l4);
        mv.visitInsn(ICONST_0);
        mv.visitInsn(IRETURN);
        mv.visitLabel(l4);

        //byte status = sa.jdoGetStatus();
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, JCN_STATE, M_SPEEDO_GET_STATUS, "()B");
        mv.visitVarInsn(ISTORE, 2);
       
        //return !LifeCycle.isTransient(status) && LifeCycle.isTransactional(status);
        mv.visitVarInsn(ILOAD, 2);
        mv.visitMethodInsn(INVOKESTATIC, JCN_LIFE_CYCLE, "isTransient", "(B)Z");
        Label l7 = new Label();
        mv.visitJumpInsn(IFNE, l7);
        mv.visitVarInsn(ILOAD, 2);
        mv.visitMethodInsn(INVOKESTATIC, JCN_LIFE_CYCLE, "isTransactional", "(B)Z");
        mv.visitJumpInsn(IFEQ, l7);
        mv.visitInsn(ICONST_1);
        Label l8 = new Label();
        mv.visitJumpInsn(GOTO, l8);
        mv.visitLabel(l7);
       
        mv.visitInsn(ICONST_0);
        mv.visitLabel(l8);
       
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here


       
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
    private void generateJdoIsPersistentMethod() {
        CodeVisitor mv;
        mv = cv.visitMethod(ACC_PUBLIC, "jdoIsPersistent", "()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.isPersistent(sa.jdoGetStatus());
        mv.visitVarInsn(ALOAD, 1);
        Label l4 = new Label();
        mv.visitJumpInsn(IFNULL, l4);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, JCN_STATE, M_SPEEDO_GET_STATUS, "()B");
        mv.visitMethodInsn(INVOKESTATIC, JCN_LIFE_CYCLE, "isPersistent", "(B)Z");
        Label l5 = new Label();
        mv.visitJumpInsn(IFEQ, l5);
        mv.visitLabel(l4);
        mv.visitInsn(ICONST_1);
        Label l6 = new Label();
        mv.visitJumpInsn(GOTO, l6);
       
        mv.visitLabel(l5);
        mv.visitInsn(ICONST_0);

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

        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

        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

        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

        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

        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

  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

  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

        } 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

TOP

Related Classes of org.objectweb.asm.CodeVisitor

Copyright © 2018 www.massapicom. 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.