class file representation of an
attribute and its API model. The attribute mapper identifies an attribute
by its name, and is used to parse the
class file representation into a model, and to write the model
representation back to a class file.
Attributes defines the mappers for predefined attributes in the JVMS
and certain conventional attributes. For other attributes (JVMS 4.7.1), users can define their own AttributeMapper; classes that
model those attributes should extend CustomAttribute. To read those
attributes, user-defined AttributeMappers must be registered to the
ClassFile..
Attributes, ClassFile.AttributeMapperOption , java.lang.classfile.attribute
| Modifier and Type | Class and Description |
|---|---|
| public static enum | AttributeMapper.
Indicates the data dependency of the |
| Modifier and Type | Method and Description |
|---|---|
| public default boolean | Returns: whether this attribute may appear more than once in one structureReturns whether this attribute may appear more than once in one structure. |
| public String | |
| public A | Returns: the read attributethe structure in which this attribute appears enclosing, ClassReader provides access to the cf, int class file to read fromthe offset into the pos)class file at which the contents
of the attribute startsCreates an |
| public AttributeMapper. | Returns: the data dependency of this attribute on theclass fileReturns the data dependency of this attribute on the |
| public void | writeAttribute(BufWriter
the buf, A BufWriter to which the attribute should be writtenthe attribute to write attr)Writes an |
| allowMultiple | back to summary |
|---|---|
| public default boolean allowMultiple() Returns whether this attribute may appear more than once in one structure.
If an attribute does not allow multiple instances in one structure,
can be supplied to a Implementation Specification The default implementation returns
| |
| name | back to summary |
|---|---|
| public String name() Returns the name of the attribute.
| |
| readAttribute | back to summary |
|---|---|
| public A readAttribute(AttributedElement enclosing, ClassReader cf, int pos) Creates an This method is called by the Class-File API to support reading of attributes. Users should never call this method. The Class-File API makes these promises about the call to this method:
The returned
API Note Implementations of this method should perform minimal work to return an
attribute, as this method is called even if the resulting attribute is
never used. In particular, the implementation should avoid checking the
validity of the attribute
| |
| stability | back to summary |
|---|---|
| public AttributeMapper. Returns the data dependency of this attribute on the
| |
| writeAttribute | back to summary |
|---|---|
| public void writeAttribute(BufWriter buf, A attr) Writes an This method is called by the Class-File API to support writing of attributes. Users should never call this method. The Class-File API makes these promises about the call to this method:
The
API Note
| |
class file representation
of an attribute. Whether an attribute can be bulk-copied by its binary
representation to a new class file depends on if its data refers
to other parts of its enclosing class file.
API Note
This dependency is called "stability" because it indicates the conditions
for a class file attribute to be eligible for bulk-copying to
another class file.
AttributeMapper#stability()
| Modifier and Type | Field and Description |
|---|---|
| public static final AttributeMapper. | CP_REFS
In addition to standalone data, the attribute refers to the constant
pool, including the |
| public static final AttributeMapper. | |
| public static final AttributeMapper. | STATELESS
The attribute contains only standalone data, and has no reference to
other parts of its enclosing |
| public static final AttributeMapper. | UNKNOWN
The attribute is completely unknown. |
| public static final AttributeMapper. | UNSTABLE
The attribute refers to structures not managed by the library (type variable lists, etc.). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static AttributeMapper. | |
| public static AttributeMapper. |
| CP_REFS | back to summary |
|---|---|
| public static final AttributeMapper. In addition to standalone data, the attribute refers to the constant
pool, including the
For example, a | |
| LABELS | back to summary |
|---|---|
| public static final AttributeMapper. In addition to standalone data and references to the constant pool,
the attribute refers to positions into the
For example, a bci value, modeled by a | |
| STATELESS | back to summary |
|---|---|
| public static final AttributeMapper. The attribute contains only standalone data, and has no reference to
other parts of its enclosing For example, a bit mask is standalone data. | |
| UNKNOWN | back to summary |
|---|---|
| public static final AttributeMapper. The attribute is completely unknown. As a result, expanding and
rewriting is not possible, and any difference between the destination
| |
| UNSTABLE | back to summary |
|---|---|
| public static final AttributeMapper. The attribute refers to structures not managed by the library (type variable lists, etc.). As a result, even when the attribute is expanded, those references may not be correctly translated, and the rewritten results may be incorrect.
If the attribute is read from a | |
| AttributeStability | back to summary |
|---|---|
| private AttributeStability() | |
| valueOf | back to summary |
|---|---|
| public static AttributeMapper. | |
| values | back to summary |
|---|---|
| public static AttributeMapper. | |