Interface AttributeMapper<A extends Attribute<A>>
- Type Parameters:
A
- the attribute type
public interface AttributeMapper<A extends Attribute<A>>
Bidirectional mapper between the classfile representation of an attribute and
how that attribute is modeled in the API. The attribute mapper is used
to parse the classfile representation into a model, and to write the model
representation back to a classfile. For each standard attribute, there is a
predefined attribute mapper defined in
Attributes
. For nonstandard
attributes, clients can define their own AttributeMapper.
Classes that model nonstandard attributes should extend CustomAttribute
.- Since:
- 24
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Attribute stability indicator -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Returns whether this attribute may appear more than once in a given location.name()
Returns the name of the attribute.readAttribute
(AttributedElement enclosing, ClassReader cf, int pos) Create anAttribute
instance from a classfile.Returns attribute stability indicator.void
writeAttribute
(BufWriter buf, A attr) Write anAttribute
instance to a classfile.
-
Method Details
-
name
-
readAttribute
Create anAttribute
instance from a classfile.- Parameters:
enclosing
- The class, method, field, or code attribute in which this attribute appearscf
- TheClassReader
describing the classfile to read frompos
- The offset into the classfile at which the attribute starts- Returns:
- the new attribute
-
writeAttribute
-
allowMultiple
default boolean allowMultiple()Returns whether this attribute may appear more than once in a given location.- Implementation Requirements:
- The default implementation returns
false
- Returns:
- whether this attribute may appear more than once in a given location
-
stability
AttributeMapper.AttributeStability stability()Returns attribute stability indicator.- Returns:
- attribute stability indicator
-