Class FieldWriter


  • final class FieldWriter
    extends FieldVisitor
    A FieldVisitor that generates a corresponding 'field_info' structure, as defined in the Java Virtual Machine Specification (JVMS).
    See Also:
    JVMS 4.5
    • Field Detail

      • symbolTable

        private final SymbolTable symbolTable
        Where the constants used in this FieldWriter must be stored.
      • accessFlags

        private final int accessFlags
        The access_flags field of the field_info JVMS structure. This field can contain ASM specific access flags, such as Opcodes.ACC_DEPRECATED, which are removed when generating the ClassFile structure.
      • nameIndex

        private final int nameIndex
        The name_index field of the field_info JVMS structure.
      • descriptorIndex

        private final int descriptorIndex
        The descriptor_index field of the field_info JVMS structure.
      • signatureIndex

        private int signatureIndex
        The signature_index field of the Signature attribute of this field_info, or 0 if there is no Signature attribute.
      • constantValueIndex

        private int constantValueIndex
        The constantvalue_index field of the ConstantValue attribute of this field_info, or 0 if there is no ConstantValue attribute.
    • Constructor Detail

      • FieldWriter

        FieldWriter​(SymbolTable symbolTable,
                    int access,
                    java.lang.String name,
                    java.lang.String descriptor,
                    java.lang.String signature,
                    java.lang.Object constantValue)
        Constructs a new FieldWriter.
        Parameters:
        symbolTable - where the constants used in this FieldWriter must be stored.
        access - the field's access flags (see Opcodes).
        name - the field's name.
        descriptor - the field's descriptor (see Type).
        signature - the field's signature. May be null.
        constantValue - the field's constant value. May be null.
    • Method Detail

      • visitAnnotation

        public AnnotationVisitor visitAnnotation​(java.lang.String descriptor,
                                                 boolean visible)
        Description copied from class: FieldVisitor
        Visits an annotation of the field.
        Overrides:
        visitAnnotation in class FieldVisitor
        Parameters:
        descriptor - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.
      • visitTypeAnnotation

        public AnnotationVisitor visitTypeAnnotation​(int typeRef,
                                                     TypePath typePath,
                                                     java.lang.String descriptor,
                                                     boolean visible)
        Description copied from class: FieldVisitor
        Visits an annotation on the type of the field.
        Overrides:
        visitTypeAnnotation in class FieldVisitor
        Parameters:
        typeRef - a reference to the annotated type. The sort of this type reference must be TypeReference.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.
        descriptor - the class descriptor of the annotation class.
        visible - true if the annotation is visible at runtime.
        Returns:
        a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.
      • visitAttribute

        public void visitAttribute​(Attribute attribute)
        Description copied from class: FieldVisitor
        Visits a non standard attribute of the field.
        Overrides:
        visitAttribute in class FieldVisitor
        Parameters:
        attribute - an attribute.
      • visitEnd

        public void visitEnd()
        Description copied from class: FieldVisitor
        Visits the end of the field. This method, which is the last one to be called, is used to inform the visitor that all the annotations and attributes of the field have been visited.
        Overrides:
        visitEnd in class FieldVisitor
      • computeFieldInfoSize

        int computeFieldInfoSize()
        Returns the size of the field_info JVMS structure generated by this FieldWriter. Also adds the names of the attributes of this field in the constant pool.
        Returns:
        the size in bytes of the field_info JVMS structure.
      • putFieldInfo

        void putFieldInfo​(ByteVector output)
        Puts the content of the field_info JVMS structure generated by this FieldWriter into the given ByteVector.
        Parameters:
        output - where the field_info structure must be put.
      • collectAttributePrototypes

        final void collectAttributePrototypes​(Attribute.Set attributePrototypes)
        Collects the attributes of this field into the given set of attribute prototypes.
        Parameters:
        attributePrototypes - a set of attribute prototypes.