Class Printer

  • Direct Known Subclasses:
    ASMifier, Textifier

    public abstract class Printer
    extends java.lang.Object
    An abstract converter from visit events to text.
    Author:
    Eric Bruneton
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int api
      The ASM API version implemented by this class.
      protected java.lang.StringBuffer buf
      A buffer that can be used to create strings.
      static java.lang.String[] HANDLE_TAG
      The names of the tag field values for Handle.
      static java.lang.String[] OPCODES
      The names of the Java Virtual Machine opcodes.
      java.util.List<java.lang.Object> text
      The text to be printed.
      static java.lang.String[] TYPES
      The names of the for operand parameter values of the MethodVisitor.visitIntInsn(int, int) method when opcode is NEWARRAY.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Printer​(int api)
      Constructs a new Printer.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void appendString​(java.lang.StringBuffer buf, java.lang.String s)
      Appends a quoted string to a given buffer.
      java.util.List<java.lang.Object> getText()
      Returns the text constructed by this visitor.
      void print​(java.io.PrintWriter pw)
      Prints the text constructed by this visitor.
      abstract void visit​(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
      Class header.
      abstract void visit​(java.lang.String name, java.lang.Object value)
      Annotation value.
      abstract Printer visitAnnotation​(java.lang.String name, java.lang.String desc)
      Nested annotation value.
      abstract Printer visitAnnotationDefault()
      Method default annotation.
      abstract void visitAnnotationEnd()
      Annotation end.
      abstract Printer visitArray​(java.lang.String name)
      Annotation array value.
      abstract Printer visitClassAnnotation​(java.lang.String desc, boolean visible)
      Class annotation.
      abstract void visitClassAttribute​(Attribute attr)
      Class attribute.
      abstract void visitClassEnd()
      Class end.
      Printer visitClassTypeAnnotation​(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
      Class type annotation.
      abstract void visitCode()
      Method start.
      abstract void visitEnum​(java.lang.String name, java.lang.String desc, java.lang.String value)
      Annotation enum value.
      abstract Printer visitField​(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
      Class field.
      abstract Printer visitFieldAnnotation​(java.lang.String desc, boolean visible)
      Field annotation.
      abstract void visitFieldAttribute​(Attribute attr)
      Field attribute.
      abstract void visitFieldEnd()
      Field end.
      abstract void visitFieldInsn​(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
      Method instruction.
      Printer visitFieldTypeAnnotation​(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
      Field type annotation.
      abstract void visitFrame​(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)
      Method stack frame.
      abstract void visitIincInsn​(int var, int increment)
      Method instruction.
      abstract void visitInnerClass​(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
      Class inner name.
      abstract void visitInsn​(int opcode)
      Method instruction.
      Printer visitInsnAnnotation​(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
      Instruction type annotation.
      abstract void visitIntInsn​(int opcode, int operand)
      Method instruction.
      abstract void visitInvokeDynamicInsn​(java.lang.String name, java.lang.String desc, Handle bsm, java.lang.Object... bsmArgs)
      Method instruction.
      abstract void visitJumpInsn​(int opcode, Label label)
      Method jump instruction.
      abstract void visitLabel​(Label label)
      Method label.
      abstract void visitLdcInsn​(java.lang.Object cst)
      Method instruction.
      abstract void visitLineNumber​(int line, Label start)
      Method debug info.
      abstract void visitLocalVariable​(java.lang.String name, java.lang.String desc, java.lang.String signature, Label start, Label end, int index)
      Method debug info.
      Printer visitLocalVariableAnnotation​(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, java.lang.String desc, boolean visible)
      Local variable type annotation.
      abstract void visitLookupSwitchInsn​(Label dflt, int[] keys, Label[] labels)
      Method instruction.
      abstract void visitMaxs​(int maxStack, int maxLocals)
      Method max stack and max locals.
      abstract Printer visitMethod​(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
      Class method.
      abstract Printer visitMethodAnnotation​(java.lang.String desc, boolean visible)
      Method annotation.
      abstract void visitMethodAttribute​(Attribute attr)
      Method attribute.
      abstract void visitMethodEnd()
      Method end.
      void visitMethodInsn​(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
      Deprecated.
      void visitMethodInsn​(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)
      Method instruction.
      Printer visitMethodTypeAnnotation​(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
      Method type annotation.
      abstract void visitMultiANewArrayInsn​(java.lang.String desc, int dims)
      Method instruction.
      abstract void visitOuterClass​(java.lang.String owner, java.lang.String name, java.lang.String desc)
      Class outer class.
      void visitParameter​(java.lang.String name, int access)
      Method parameter.
      abstract Printer visitParameterAnnotation​(int parameter, java.lang.String desc, boolean visible)
      Method parameter annotation.
      abstract void visitSource​(java.lang.String source, java.lang.String debug)
      Class source.
      abstract void visitTableSwitchInsn​(int min, int max, Label dflt, Label... labels)
      Method instruction.
      Printer visitTryCatchAnnotation​(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
      Try catch block type annotation.
      abstract void visitTryCatchBlock​(Label start, Label end, Label handler, java.lang.String type)
      Method exception handler.
      abstract void visitTypeInsn​(int opcode, java.lang.String type)
      Method instruction.
      abstract void visitVarInsn​(int opcode, int var)
      Method instruction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OPCODES

        public static final java.lang.String[] OPCODES
        The names of the Java Virtual Machine opcodes.
      • HANDLE_TAG

        public static final java.lang.String[] HANDLE_TAG
        The names of the tag field values for Handle.
      • api

        protected final int api
        The ASM API version implemented by this class. The value of this field must be one of Opcodes.ASM4 or Opcodes.ASM5.
      • buf

        protected final java.lang.StringBuffer buf
        A buffer that can be used to create strings.
      • text

        public final java.util.List<java.lang.Object> text
        The text to be printed. Since the code of methods is not necessarily visited in sequential order, one method after the other, but can be interlaced (some instructions from method one, then some instructions from method two, then some instructions from method one again...), it is not possible to print the visited instructions directly to a sequential stream. A class is therefore printed in a two steps process: a string tree is constructed during the visit, and printed to a sequential stream at the end of the visit. This string tree is stored in this field, as a string list that can contain other string lists, which can themselves contain other string lists, and so on.
    • Constructor Detail

      • Printer

        protected Printer​(int api)
        Constructs a new Printer.
        Parameters:
        api - the ASM API version implemented by this printer. Must be one of Opcodes.ASM4 or Opcodes.ASM5.
    • Method Detail

      • visit

        public abstract void visit​(int version,
                                   int access,
                                   java.lang.String name,
                                   java.lang.String signature,
                                   java.lang.String superName,
                                   java.lang.String[] interfaces)
        Parameters:
        version - the class version.
        access - the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated.
        name - the internal name of the class (see getInternalName).
        signature - the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
        superName - the internal of name of the super class (see getInternalName). For interfaces, the super class is Object. May be null, but only for the Object class.
        interfaces - the internal names of the class's interfaces (see getInternalName). May be null.
      • visitSource

        public abstract void visitSource​(java.lang.String source,
                                         java.lang.String debug)
        Parameters:
        source - the name of the source file from which the class was compiled. May be null.
        debug - additional debug information to compute the correspondance between source and compiled elements of the class. May be null.
      • visitOuterClass

        public abstract void visitOuterClass​(java.lang.String owner,
                                             java.lang.String name,
                                             java.lang.String desc)
        Class outer class. See ClassVisitor.visitOuterClass(java.lang.String, java.lang.String, java.lang.String). Visits the enclosing class of the class. This method must be called only if the class has an enclosing class.
        Parameters:
        owner - internal name of the enclosing class of the class.
        name - the name of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
        desc - the descriptor of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
      • visitClassAnnotation

        public abstract Printer visitClassAnnotation​(java.lang.String desc,
                                                     boolean visible)
        Parameters:
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitInnerClass

        public abstract void visitInnerClass​(java.lang.String name,
                                             java.lang.String outerName,
                                             java.lang.String innerName,
                                             int access)
        Parameters:
        name - the internal name of an inner class (see getInternalName).
        outerName - the internal name of the class to which the inner class belongs (see getInternalName). May be null for not member classes.
        innerName - the (simple) name of the inner class inside its enclosing class. May be null for anonymous inner classes.
        access - the access flags of the inner class as originally declared in the enclosing class.
      • visitField

        public abstract Printer visitField​(int access,
                                           java.lang.String name,
                                           java.lang.String desc,
                                           java.lang.String signature,
                                           java.lang.Object value)
        Parameters:
        access - the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.
        name - the field's name.
        desc - the field's descriptor (see Type).
        signature - the field's signature. May be null if the field's type does not use generic types.
        value - the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.
        Returns:
        the printer
      • visitMethod

        public abstract Printer visitMethod​(int access,
                                            java.lang.String name,
                                            java.lang.String desc,
                                            java.lang.String signature,
                                            java.lang.String[] exceptions)
        Parameters:
        access - the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
        name - the method's name.
        desc - the method's descriptor (see Type).
        signature - the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
        exceptions - the internal names of the method's exception classes (see getInternalName). May be null.
        Returns:
        the printer
      • visit

        public abstract void visit​(java.lang.String name,
                                   java.lang.Object value)
        Parameters:
        name - the value name.
        value - the actual value, whose type must be Byte, Boolean, Character, Short, Integer , Long, Float, Double, String or Type or OBJECT or ARRAY sort. This value can also be an array of byte, boolean, short, char, int, long, float or double values (this is equivalent to using visitArray and visiting each array element in turn, but is more convenient).
      • visitArray

        public abstract Printer visitArray​(java.lang.String name)
        Annotation array value. See AnnotationVisitor.visitArray(java.lang.String). Visits an array value of the annotation. Note that arrays of primitive types (such as byte, boolean, short, char, int, long, float or double) can be passed as value to visit. This is what ClassReader does.
        Parameters:
        name - the value name.
        Returns:
        the printer
      • visitFieldAnnotation

        public abstract Printer visitFieldAnnotation​(java.lang.String desc,
                                                     boolean visible)
        Parameters:
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitFieldTypeAnnotation

        public Printer visitFieldTypeAnnotation​(int typeRef,
                                                TypePath typePath,
                                                java.lang.String desc,
                                                boolean visible)
        Parameters:
        typeRef - a reference to the annotated type. The sort of this type reference must be FIELD. See TypeReference.
        typePath - the path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be null if the annotation targets 'typeRef' as a whole.
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitParameter

        public void visitParameter​(java.lang.String name,
                                   int access)
        Parameters:
        name - parameter name or null if none is provided.
        access - the parameter's access flags, only ACC_FINAL, ACC_SYNTHETIC or/and ACC_MANDATED are allowed (see Opcodes).
      • visitMethodAnnotation

        public abstract Printer visitMethodAnnotation​(java.lang.String desc,
                                                      boolean visible)
        Parameters:
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitMethodTypeAnnotation

        public Printer visitMethodTypeAnnotation​(int typeRef,
                                                 TypePath typePath,
                                                 java.lang.String desc,
                                                 boolean visible)
        Parameters:
        typeRef - a reference to the annotated type. The sort of this type reference must be FIELD. See TypeReference.
        typePath - the path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be null if the annotation targets 'typeRef' as a whole.
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitParameterAnnotation

        public abstract Printer visitParameterAnnotation​(int parameter,
                                                         java.lang.String desc,
                                                         boolean visible)
        Parameters:
        parameter - the parameter index.
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitFrame

        public abstract void visitFrame​(int type,
                                        int nLocal,
                                        java.lang.Object[] local,
                                        int nStack,
                                        java.lang.Object[] stack)
        Method stack frame. See MethodVisitor.visitFrame(int, int, java.lang.Object[], int, java.lang.Object[]). Visits the current state of the local variables and operand stack elements. This method must(*) be called just before any instruction i that follows an unconditional branch instruction such as GOTO or THROW, that is the target of a jump instruction, or that starts an exception handler block. The visited types must describe the values of the local variables and of the operand stack elements just before i is executed.

        (*) this is mandatory only for classes whose version is greater than or equal to V1_6.

        The frames of a method must be given either in expanded form, or in compressed form (all frames must use the same format, i.e. you must not mix expanded and compressed frames within a single method):
        • In expanded form, all frames must have the F_NEW type.
        • In compressed form, frames are basically "deltas" from the state of the previous frame:
          • Opcodes.F_SAME representing frame with exactly the same locals as the previous frame and with the empty stack.
          • Opcodes.F_SAME1 representing frame with exactly the same locals as the previous frame and with single value on the stack ( nStack is 1 and stack[0] contains value for the type of the stack item).
          • Opcodes.F_APPEND representing frame with current locals are the same as the locals in the previous frame, except that additional locals are defined (nLocal is 1, 2 or 3 and local elements contains values representing added types).
          • Opcodes.F_CHOP representing frame with current locals are the same as the locals in the previous frame, except that the last 1-3 locals are absent and with the empty stack (nLocals is 1, 2 or 3).
          • Opcodes.F_FULL representing complete frame data.

        In both cases the first frame, corresponding to the method's parameters and access flags, is implicit and must not be visited. Also, it is illegal to visit two or more frames for the same code location (i.e., at least one instruction must be visited between two calls to visitFrame).
        Parameters:
        type - the type of this stack map frame. Must be Opcodes.F_NEW for expanded frames, or Opcodes.F_FULL, Opcodes.F_APPEND, Opcodes.F_CHOP, Opcodes.F_SAME or Opcodes.F_APPEND, Opcodes.F_SAME1 for compressed frames.
        nLocal - the number of local variables in the visited frame.
        local - the local variable types in this frame. This array must not be modified. Primitive types are represented by Opcodes.TOP, Opcodes.INTEGER, Opcodes.FLOAT, Opcodes.LONG, Opcodes.DOUBLE,Opcodes.NULL or Opcodes.UNINITIALIZED_THIS (long and double are represented by a single element). Reference types are represented by String objects (representing internal names), and uninitialized types by Label objects (this label designates the NEW instruction that created this uninitialized value).
        nStack - the number of operand stack elements in the visited frame.
        stack - the operand stack types in this frame. This array must not be modified. Its content has the same format as the "local" array.
        Throws:
        java.lang.IllegalStateException - if a frame is visited just after another one, without any instruction between the two (unless this frame is a Opcodes#F_SAME frame, in which case it is silently ignored).
      • visitInsn

        public abstract void visitInsn​(int opcode)
        Method instruction. See MethodVisitor.visitInsn(int)
        Parameters:
        opcode - the opcode of the instruction to be visited. This opcode is either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, or MONITOREXIT.
      • visitVarInsn

        public abstract void visitVarInsn​(int opcode,
                                          int var)
        Method instruction. See MethodVisitor.visitVarInsn(int, int).
        Parameters:
        opcode - the opcode of the local variable instruction to be visited. This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
        var - the operand of the instruction to be visited. This operand is the index of a local variable.
      • visitTypeInsn

        public abstract void visitTypeInsn​(int opcode,
                                           java.lang.String type)
        Method instruction. See MethodVisitor.visitTypeInsn(int, java.lang.String). /** Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as parameter.
        Parameters:
        opcode - the opcode of the type instruction to be visited. This opcode is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
        type - the operand of the instruction to be visited. This operand must be the internal name of an object or array class (see getInternalName).
      • visitFieldInsn

        public abstract void visitFieldInsn​(int opcode,
                                            java.lang.String owner,
                                            java.lang.String name,
                                            java.lang.String desc)
        Parameters:
        opcode - the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
        owner - the internal name of the field's owner class (see getInternalName).
        name - the field's name.
        desc - the field's descriptor (see Type).
      • visitMethodInsn

        @Deprecated
        public void visitMethodInsn​(int opcode,
                                    java.lang.String owner,
                                    java.lang.String name,
                                    java.lang.String desc)
        Deprecated.
        Parameters:
        opcode - the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
        owner - the internal name of the method's owner class (see getInternalName).
        name - the method's name.
        desc - the method's descriptor (see Type).
      • visitMethodInsn

        public void visitMethodInsn​(int opcode,
                                    java.lang.String owner,
                                    java.lang.String name,
                                    java.lang.String desc,
                                    boolean itf)
        Parameters:
        opcode - the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
        owner - the internal name of the method's owner class (see getInternalName).
        name - the method's name.
        desc - the method's descriptor (see Type).
        itf - if the method's owner class is an interface.
      • visitInvokeDynamicInsn

        public abstract void visitInvokeDynamicInsn​(java.lang.String name,
                                                    java.lang.String desc,
                                                    Handle bsm,
                                                    java.lang.Object... bsmArgs)
        Parameters:
        name - the method's name.
        desc - the method's descriptor (see Type).
        bsm - the bootstrap method.
        bsmArgs - the bootstrap method constant arguments. Each argument must be an Integer, Float, Long, Double, String, Type or Handle value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
      • visitJumpInsn

        public abstract void visitJumpInsn​(int opcode,
                                           Label label)
        Parameters:
        opcode - the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
        label - the operand of the instruction to be visited. This operand is a label that designates the instruction to which the jump instruction may jump.
      • visitLdcInsn

        public abstract void visitLdcInsn​(java.lang.Object cst)
        Method instruction. See MethodVisitor.visitLdcInsn(java.lang.Object). Visits a LDC instruction. Note that new constant types may be added in future versions of the Java Virtual Machine. To easily detect new constant types, implementations of this method should check for unexpected constant types, like this:
         if (cst instanceof Integer) {
             // ...
         } else if (cst instanceof Float) {
             // ...
         } else if (cst instanceof Long) {
             // ...
         } else if (cst instanceof Double) {
             // ...
         } else if (cst instanceof String) {
             // ...
         } else if (cst instanceof Type) {
             int sort = ((Type) cst).getSort();
             if (sort == Type.OBJECT) {
                 // ...
             } else if (sort == Type.ARRAY) {
                 // ...
             } else if (sort == Type.METHOD) {
                 // ...
             } else {
                 // throw an exception
             }
         } else if (cst instanceof Handle) {
             // ...
         } else {
             // throw an exception
         }
         
        Parameters:
        cst - the constant to be loaded on the stack. This parameter must be a non null Integer, a Float, a Long, a Double, a String, a Type of OBJECT or ARRAY sort for .class constants, for classes whose version is 49.0, a Type of METHOD sort or a Handle for MethodType and MethodHandle constants, for classes whose version is 51.0.
      • visitIincInsn

        public abstract void visitIincInsn​(int var,
                                           int increment)
        Method instruction. See MethodVisitor.visitIincInsn(int, int).
        Parameters:
        var - index of the local variable to be incremented.
        increment - amount to increment the local variable by.
      • visitTryCatchAnnotation

        public Printer visitTryCatchAnnotation​(int typeRef,
                                               TypePath typePath,
                                               java.lang.String desc,
                                               boolean visible)
        Parameters:
        typeRef - a reference to the annotated type. The sort of this type reference must be EXCEPTION_PARAMETER. See TypeReference.
        typePath - the path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be null if the annotation targets 'typeRef' as a whole.
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitLocalVariable

        public abstract void visitLocalVariable​(java.lang.String name,
                                                java.lang.String desc,
                                                java.lang.String signature,
                                                Label start,
                                                Label end,
                                                int index)
        Parameters:
        name - the name of a local variable.
        desc - the type descriptor of this local variable.
        signature - the type signature of this local variable. May be null if the local variable type does not use generic types.
        start - the first instruction corresponding to the scope of this local variable (inclusive).
        end - the last instruction corresponding to the scope of this local variable (exclusive).
        index - the local variable's index.
        Throws:
        java.lang.IllegalArgumentException - if one of the labels has not already been visited by this visitor (by the visitLabel method).
      • visitLocalVariableAnnotation

        public Printer visitLocalVariableAnnotation​(int typeRef,
                                                    TypePath typePath,
                                                    Label[] start,
                                                    Label[] end,
                                                    int[] index,
                                                    java.lang.String desc,
                                                    boolean visible)
        Parameters:
        typeRef - a reference to the annotated type. The sort of this type reference must be LOCAL_VARIABLE or RESOURCE_VARIABLE. See TypeReference.
        typePath - the path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be null if the annotation targets 'typeRef' as a whole.
        start - the fist instructions corresponding to the continuous ranges that make the scope of this local variable (inclusive).
        end - the last instructions corresponding to the continuous ranges that make the scope of this local variable (exclusive). This array must have the same size as the 'start' array.
        index - the local variable's index in each range. This array must have the same size as the 'start' array.
        desc - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        the printer
      • visitLineNumber

        public abstract void visitLineNumber​(int line,
                                             Label start)
        Parameters:
        line - a line number. This number refers to the source file from which the class was compiled.
        start - the first instruction corresponding to this line number.
        Throws:
        java.lang.IllegalArgumentException - if start has not already been visited by this visitor (by the visitLabel method).
      • visitMaxs

        public abstract void visitMaxs​(int maxStack,
                                       int maxLocals)
        Method max stack and max locals. See MethodVisitor.visitMaxs(int, int).
        Parameters:
        maxStack - maximum stack size of the method.
        maxLocals - maximum number of local variables for the method.
      • getText

        public java.util.List<java.lang.Object> getText()
        Returns the text constructed by this visitor.
        Returns:
        the text constructed by this visitor.
      • print

        public void print​(java.io.PrintWriter pw)
        Prints the text constructed by this visitor.
        Parameters:
        pw - the print writer to be used.
      • appendString

        public static void appendString​(java.lang.StringBuffer buf,
                                        java.lang.String s)
        Appends a quoted string to a given buffer.
        Parameters:
        buf - the buffer where the string must be added.
        s - the string to be added.