..Annotations_attribute.
See the source code of the AnnotationsAttribute.Copier class.
The following code snippet is an example of use of this class:
ConstPool pool = ...;
output = new ByteArrayOutputStream();
writer = new AnnotationsWriter(output, pool);
writer.numAnnotations(1);
writer.annotation("Author", 2);
writer.memberValuePair("name"); // element_value_pair
writer.constValueIndex("chiba");
writer.memberValuePair("address"); // element_value_pair
writer.constValueIndex("tokyo");
writer.close();
byte[] attribute_info = output.toByteArray();
AnnotationsAttribute anno
= new AnnotationsAttribute(pool, AnnotationsAttribute.visibleTag,
attribute_info);
The code snippet above generates the annotation attribute corresponding to this annotation:
@Author(name = "chiba", address = "tokyo")
javassist.bytecode.AnnotationsAttribute , javassist.bytecode.ParameterAnnotationsAttribute
| Modifier and Type | Field and Description |
|---|---|
| protected OutputStream | |
| private ConstPool |
| Access | Constructor and Description |
|---|---|
| public | AnnotationsWriter(OutputStream
the output stream. os, ConstPool the constant pool. cp)Constructs with the given output stream. |
| Modifier and Type | Method and Description |
|---|---|
| public void | annotation(String
the annotation interface name. type, int num_element_value_pairs
in annotation.Writes |
| public void | annotation(int
type_index in annotation.num_element_value_pairs
in annotation.Writes |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | constValueIndex(int
tag in element_value.const_value_index
in element_value.Writes |
| public void | enumConstValue(String
the type name of the enum constant. typeName, String the simple name of the enum constant. constName)Writes |
| public void | enumConstValue(int
type_name_index
in element_value.const_name_index
in element_value.Writes |
| public ConstPool | |
| public void | memberValuePair(String
the element name. memberName)Writes an element of a |
| public void | memberValuePair(int
element_name_index
in element_value_pairs array.Writes an element of a |
| public void | |
| public void | |
| protected void |
| output | back to summary |
|---|---|
| protected OutputStream output | |
| pool | back to summary |
|---|---|
| private ConstPool pool | |
| AnnotationsWriter | back to summary |
|---|---|
| public AnnotationsWriter(OutputStream os, ConstPool cp) Constructs with the given output stream.
| |
| annotation | back to summary |
|---|---|
| public void annotation(String type, int numMemberValuePairs) throws IOException Writes
| |
| annotation | back to summary |
|---|---|
| public void annotation(int typeIndex, int numMemberValuePairs) throws IOException Writes
| |
| annotationValue | back to summary |
|---|---|
| public void annotationValue() throws IOException Writes | |
| arrayValue | back to summary |
|---|---|
| public void arrayValue(int numValues) throws IOException Writes
| |
| classInfoIndex | back to summary |
|---|---|
| public void classInfoIndex(String name) throws IOException Writes
| |
| classInfoIndex | back to summary |
|---|---|
| public void classInfoIndex(int index) throws IOException Writes
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Closes the output stream. | |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(boolean value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(byte value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(char value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(short value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(int value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(long value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(float value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(double value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(String value) throws IOException Writes
| |
| constValueIndex | back to summary |
|---|---|
| public void constValueIndex(int tag, int index) throws IOException Writes
| |
| enumConstValue | back to summary |
|---|---|
| public void enumConstValue(String typeName, String constName) throws IOException Writes | |
| enumConstValue | back to summary |
|---|---|
| public void enumConstValue(int typeNameIndex, int constNameIndex) throws IOException Writes
| |
| getConstPool | back to summary |
|---|---|
| public ConstPool getConstPool() Obtains the constant pool given to the constructor. | |
| memberValuePair | back to summary |
|---|---|
| public void memberValuePair(String memberName) throws IOException Writes an element of a
| |
| memberValuePair | back to summary |
|---|---|
| public void memberValuePair(int memberNameIndex) throws IOException Writes an element of a
| |
| numAnnotations | back to summary |
|---|---|
| public void numAnnotations(int num) throws IOException Writes | |
| numParameters | back to summary |
|---|---|
| public void numParameters(int num) throws IOException Writes | |
| write16bit | back to summary |
|---|---|
| protected void write16bit(int value) throws IOException | |