APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.classfile

public abstract non-sealed Class CustomAttribute<T extends CustomAttribute<T>>

extends Object
implements Attribute<T extends CustomAttribute<T>>, CodeElement, ClassElement, MethodElement, FieldElement
Class Inheritance
All Implemented Interfaces
java.lang.classfile.FieldElement, java.lang.classfile.ClassFileElement, java.lang.classfile.MethodElement, java.lang.classfile.ClassElement, java.lang.classfile.CodeElement, java.lang.classfile.Attribute
Type Parameters
<T>
the custom attribute type
Imports
java.lang.classfile.constantpool.PoolEntry, .Utf8Entry, jdk.internal.classfile.impl.TemporaryConstantPool

Models a user-defined attribute in a class file. API models for user-defined attributes should extend this class. A user-defined attribute should also have an AttributeMapper defined, which will be returned by attributeMapper, and registered to the ClassFile.AttributeMapperOption so the user-defined attributes can be read.

Accessor methods on user-defined attributes read from class files may throw IllegalArgumentException if the attribute model is lazily evaluated, and the evaluation encounters malformed class file format for the attribute.

Since
24
See Also
java.lang.classfile.attribute

Field Summary

Modifier and TypeField and Description
private final AttributeMapper<T>

Constructor Summary

AccessConstructor and Description
protected
CustomAttribute(AttributeMapper<T>
the attribute mapper
mapper
)

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public final AttributeMapper<T>
attributeMapper()

Implements java.lang.classfile.Attribute.attributeMapper.

Returns the AttributeMapper associated with this attribute.

public Utf8Entry
attributeName()

Implements java.lang.classfile.Attribute.attributeName.

Returns the name of the attribute.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mapperback to summary
private final AttributeMapper<T> mapper

Constructor Detail

CustomAttributeback to summary
protected CustomAttribute(AttributeMapper<T> mapper)

Constructor for subclasses to call.

Parameters
mapper:AttributeMapper<T>

the attribute mapper

Method Detail

attributeMapperback to summary
public final AttributeMapper<T> attributeMapper()

Implements java.lang.classfile.Attribute.attributeMapper.

Doc from java.lang.classfile.Attribute.attributeMapper.

Returns the AttributeMapper associated with this attribute.

Annotations
@Override
attributeNameback to summary
public Utf8Entry attributeName()

Implements java.lang.classfile.Attribute.attributeName.

Doc from java.lang.classfile.Attribute.attributeName.

Returns the name of the attribute. The string value of the name is equivalent to the value of attributeMapper().name().

If this attribute is read from a class file, this method returns the Utf8Entry indicating the attribute name in the class file.

Implementation Specification

The default implementation returns a Utf8Entry suitable for writing only, which may be unbound. Subclasses representing attributes read from class files must override this method.

Annotations
@Override
See Also
AttributeMapper#readAttribute
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override