AnnotationVisitor that generates a corresponding 'annotation' or 'type_annotation'
structure, as defined in the Java Virtual Machine Specification (JVMS). AnnotationWriter
instances can be chained in a doubly linked list, from which Runtime[In]Visible[Type]Annotations
attributes can be generated with the putAnnotations method. Similarly, arrays of such
lists can be used to generate Runtime[In]VisibleParameterAnnotations attributes.
| Modifier and Type | Field and Description |
|---|---|
| private final ByteVector | annotation
The 'annotation' or 'type_annotation' JVMS structure corresponding to the annotation values visited so far. |
| private AnnotationWriter | nextAnnotation
The next AnnotationWriter. |
| private int | numElementValuePairs
The number of element value pairs visited so far. |
| private final int | numElementValuePairsOffset
The offset in |
| private final AnnotationWriter | previousAnnotation
The previous AnnotationWriter. |
| private final SymbolTable | symbolTable
Where the constants used in this AnnotationWriter must be stored. |
| private final boolean | useNamedValues
Whether values are named or not. |
| Access | Constructor and Description |
|---|---|
| pack-priv | AnnotationWriter(final SymbolTable
where the constants used in this AnnotationWriter must be stored. symbolTable, final boolean whether values are named or not. AnnotationDefault and annotation arrays
use unnamed values. useNamedValues, final ByteVector where the 'annotation' or 'type_annotation' JVMS structure corresponding to
the visited content must be stored. This ByteVector must already contain all the fields of
the structure except the last one (the element_value_pairs array). annotation, final AnnotationWriter the previously visited annotation of the
Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
null in other cases (e.g. nested or array annotations). previousAnnotation)Constructs a new |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | Returns: the size in bytes of a Runtime[In]Visible[Type]Annotations attribute containing this annotation and all its predecessors. This includes the size of the attribute_name_index and attribute_length fields.one of "Runtime[In]Visible[Type]Annotations", or null. attributeName)Returns the size of a Runtime[In]Visible[Type]Annotations attribute containing this annotation
and all its predecessors (see |
| pack-priv static int | Returns: the size in bytes of a Runtime[In]Visible[Type]Annotations attribute containing the given annotations and all their predecessors. This includes the size of the attribute_name_index and attribute_length fields.The last runtime visible annotation of a field, method or
class. The previous ones can be accessed with the lastRuntimeVisibleAnnotation, final AnnotationWriter previousAnnotation field. May be
null.The last runtime invisible annotation of this a field,
method or class. The previous ones can be accessed with the lastRuntimeInvisibleAnnotation, final AnnotationWriter previousAnnotation
field. May be null.The last runtime visible type annotation of this a
field, method or class. The previous ones can be accessed with the lastRuntimeVisibleTypeAnnotation, final AnnotationWriter previousAnnotation field. May be null.The last runtime invisible type annotation of a
field, method or class field. The previous ones can be accessed with the lastRuntimeInvisibleTypeAnnotation)previousAnnotation field. May be null.Returns the size of the Runtime[In]Visible[Type]Annotations attributes containing the given
annotations and all their predecessors (see |
| pack-priv static int | Returns: the size in bytes of a Runtime[In]VisibleParameterAnnotations attribute corresponding to the given sub-array of AnnotationWriter lists. This includes the size of the attribute_name_index and attribute_length fields.one of "Runtime[In]VisibleParameterAnnotations". attributeName, final AnnotationWriter[] an array of AnnotationWriter lists (designated by their last
element). annotationWriters, final int the number of elements in annotationWriters to take into account
(elements [0..annotableParameterCount[ are taken into account). annotableParameterCount)Returns the size of a Runtime[In]VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub-array. |
| pack-priv static AnnotationWriter | Returns: a newAnnotationWriter for the given annotation descriptor.where the constants used in this AnnotationWriter must be stored. symbolTable, final String the class descriptor of the annotation class. descriptor, final AnnotationWriter the previously visited annotation of the
Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
null in other cases (e.g. nested or array annotations). previousAnnotation)Creates a new |
| pack-priv static AnnotationWriter | Returns: a newAnnotationWriter for the given type annotation reference and descriptor.where the constants used in this AnnotationWriter must be stored. symbolTable, final int a reference to the annotated type. The sort of this type reference must be
typeRef, final TypePath TypeReference#CLASS_TYPE_PARAMETER, TypeReference#CLASS_TYPE_PARAMETER_BOUND or TypeReference#CLASS_EXTENDS. See
TypeReference.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. typePath, final String the class descriptor of the annotation class. descriptor, final AnnotationWriter the previously visited annotation of the
Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
null in other cases (e.g. nested or array annotations). previousAnnotation)Creates a new |
| pack-priv void | putAnnotations(final int
the constant pool index of the attribute name (one of
"Runtime[In]Visible[Type]Annotations"). attributeNameIndex, final ByteVector where the attribute must be put. output)Puts a Runtime[In]Visible[Type]Annotations attribute containing this annotations and all its
predecessors (see |
| pack-priv static void | putAnnotations(final SymbolTable
where the constants used in the AnnotationWriter instances are stored. symbolTable, final AnnotationWriter The last runtime visible annotation of a field, method or
class. The previous ones can be accessed with the lastRuntimeVisibleAnnotation, final AnnotationWriter previousAnnotation field. May be
null.The last runtime invisible annotation of this a field,
method or class. The previous ones can be accessed with the lastRuntimeInvisibleAnnotation, final AnnotationWriter previousAnnotation
field. May be null.The last runtime visible type annotation of this a
field, method or class. The previous ones can be accessed with the lastRuntimeVisibleTypeAnnotation, final AnnotationWriter previousAnnotation field. May be null.The last runtime invisible type annotation of a
field, method or class field. The previous ones can be accessed with the lastRuntimeInvisibleTypeAnnotation, final ByteVector previousAnnotation field. May be null.where the attributes must be put. output)Puts the Runtime[In]Visible[Type]Annotations attributes containing the given annotations and
all their predecessors (see |
| pack-priv static void | putParameterAnnotations(final int
constant pool index of the attribute name (one of
Runtime[In]VisibleParameterAnnotations). attributeNameIndex, final AnnotationWriter[] an array of AnnotationWriter lists (designated by their last
element). annotationWriters, final int the number of elements in annotationWriters to put (elements
[0..annotableParameterCount[ are put). annotableParameterCount, final ByteVector where the attribute must be put. output)Puts a Runtime[In]VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub-array in the given ByteVector. |
| public void | visit(final String
the value name. name, final Object the actual value, whose type must be value)
Visits a primitive value of the annotation.
Byte, Boolean, Character, Short, Integer , Long, Float, Double,
String or Type of Type#OBJECT or Type#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). |
| public AnnotationVisitor | visitAnnotation(final String
the value name. name, final String the class descriptor of the nested annotation class. descriptor)Overrides net. |
| public AnnotationVisitor | visitArray(final String
the value name. name)Overrides net. |
| public void | visitEnd()
Visits the end of the annotation.
|
| public void | visitEnum(final String
the value name. name, final String the class descriptor of the enumeration class. descriptor, final String the actual enumeration value. value)Overrides net. |
| annotation | back to summary |
|---|---|
| private final ByteVector annotation The 'annotation' or 'type_annotation' JVMS structure corresponding to the annotation values
visited so far. All the fields of these structures, except the last one - the
element_value_pairs array, must be set before this ByteVector is passed to the constructor
(num_element_value_pairs can be set to 0, it is reset to the correct value in Note as an exception to the above rules, for AnnotationDefault attributes (which contain a
single element_value by definition), this ByteVector is initially empty when passed to the
constructor, and | |
| nextAnnotation | back to summary |
|---|---|
| private AnnotationWriter nextAnnotation The next AnnotationWriter. This field is used to store the list of annotations of a Runtime[In]Visible[Type]Annotations attribute. It is unused for nested or array annotations (annotation values of annotation type), or for AnnotationDefault attributes. | |
| numElementValuePairs | back to summary |
|---|---|
| private int numElementValuePairs The number of element value pairs visited so far. | |
| numElementValuePairsOffset | back to summary |
|---|---|
| private final int numElementValuePairsOffset The offset in | |
| previousAnnotation | back to summary |
|---|---|
| private final AnnotationWriter previousAnnotation The previous AnnotationWriter. This field is used to store the list of annotations of a Runtime[In]Visible[Type]Annotations attribute. It is unused for nested or array annotations (annotation values of annotation type), or for AnnotationDefault attributes. | |
| symbolTable | back to summary |
|---|---|
| private final SymbolTable symbolTable Where the constants used in this AnnotationWriter must be stored. | |
| useNamedValues | back to summary |
|---|---|
| private final boolean useNamedValues Whether values are named or not. AnnotationWriter instances used for annotation default and annotation arrays use unnamed values (i.e. they generate an 'element_value' structure for each value, instead of an element_name_index followed by an element_value). | |
| AnnotationWriter | back to summary |
|---|---|
| pack-priv AnnotationWriter(final SymbolTable symbolTable, final boolean useNamedValues, final ByteVector annotation, final AnnotationWriter previousAnnotation) Constructs a new
| |
| computeAnnotationsSize | back to summary |
|---|---|
| pack-priv int computeAnnotationsSize(final String attributeName) Returns the size of a Runtime[In]Visible[Type]Annotations attribute containing this annotation
and all its predecessors (see
| |
| computeAnnotationsSize | back to summary |
|---|---|
| pack-priv static int computeAnnotationsSize(final AnnotationWriter lastRuntimeVisibleAnnotation, final AnnotationWriter lastRuntimeInvisibleAnnotation, final AnnotationWriter lastRuntimeVisibleTypeAnnotation, final AnnotationWriter lastRuntimeInvisibleTypeAnnotation) Returns the size of the Runtime[In]Visible[Type]Annotations attributes containing the given
annotations and all their predecessors (see
| |
| computeParameterAnnotationsSize | back to summary |
|---|---|
| pack-priv static int computeParameterAnnotationsSize(final String attributeName, final AnnotationWriter[] annotationWriters, final int annotableParameterCount) Returns the size of a Runtime[In]VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub-array. Also adds the attribute name to the constant pool of the class.
| |
| create | back to summary |
|---|---|
| pack-priv static AnnotationWriter create(final SymbolTable symbolTable, final String descriptor, final AnnotationWriter previousAnnotation) Creates a new
| |
| create | back to summary |
|---|---|
| pack-priv static AnnotationWriter create(final SymbolTable symbolTable, final int typeRef, final TypePath typePath, final String descriptor, final AnnotationWriter previousAnnotation) Creates a new
| |
| putAnnotations | back to summary |
|---|---|
| pack-priv void putAnnotations(final int attributeNameIndex, final ByteVector output) Puts a Runtime[In]Visible[Type]Annotations attribute containing this annotations and all its
predecessors (see
| |
| putAnnotations | back to summary |
|---|---|
| pack-priv static void putAnnotations(final SymbolTable symbolTable, final AnnotationWriter lastRuntimeVisibleAnnotation, final AnnotationWriter lastRuntimeInvisibleAnnotation, final AnnotationWriter lastRuntimeVisibleTypeAnnotation, final AnnotationWriter lastRuntimeInvisibleTypeAnnotation, final ByteVector output) Puts the Runtime[In]Visible[Type]Annotations attributes containing the given annotations and
all their predecessors (see
| |
| putParameterAnnotations | back to summary |
|---|---|
| pack-priv static void putParameterAnnotations(final int attributeNameIndex, final AnnotationWriter[] annotationWriters, final int annotableParameterCount, final ByteVector output) Puts a Runtime[In]VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub-array in the given ByteVector.
| |
| visit | back to summary |
|---|---|
| public void visit(final String name, final Object value) Overrides net. Doc from net. Visits a primitive value of the annotation.
| |
| visitAnnotation | back to summary |
|---|---|
| public AnnotationVisitor visitAnnotation(final String name, final String descriptor) Overrides net. Doc from net. Visits a nested annotation value of the annotation.
| |
| visitArray | back to summary |
|---|---|
| public AnnotationVisitor visitArray(final String name) Overrides net. Doc from net. Visits an array value of the annotation. Note that arrays of primitive values (such as byte,
boolean, short, char, int, long, float or double) can be passed as value to
| |
| visitEnd | back to summary |
|---|---|
| public void visitEnd() Overrides net. Doc from net. Visits the end of the annotation.
| |
| visitEnum | back to summary |
|---|---|
| public void visitEnum(final String name, final String descriptor, final String value) Overrides net. Doc from net. Visits an enumeration value of the annotation. | |