APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ConstantValueAttribute

extends Attribute<ConstantValueAttribute>, FieldElement
permits BoundConstantValueAttribute, UnboundConstantValueAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundConstantValueAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundConstantValueAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassFile, .FieldElement, java.lang.classfile.constantpool.ConstantValueEntry, java.lang.constant.ConstantDesc, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

Models the ConstantValue attribute (JVMS 4.7.2), which indicates this field's value is a constant and that constant value.

This attribute only appears on fields, and does not permit multiple instances in a field. It has a data dependency on the constant pool.

This attribute was introduced in the Java Platform version 1.0.2, major version 45.

Since
24
Java Virtual Machine Specification
4.7.2 The ConstantValue Attribute
See Also
Attributes#constantValue()

Method Summary

Modifier and TypeMethod and Description
public ConstantValueEntry

Returns:

the constant value of the field
constant
()

Returns the constant value of the field.

public static ConstantValueAttribute

Returns:

a ConstantValue attribute
of
(ConstantValueEntry
the constant value
value
)

Returns a ConstantValue attribute.

public static ConstantValueAttribute

Returns:

a ConstantValue attribute
of
(ConstantDesc
the constant value
value
)

Returns a ConstantValue attribute.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

constantback to summary
public ConstantValueEntry constant()

Returns the constant value of the field.

Returns:ConstantValueEntry

the constant value of the field

ofback to summary
public static ConstantValueAttribute of(ConstantValueEntry value)

Returns a ConstantValue attribute.

Parameters
value:ConstantValueEntry

the constant value

Returns:ConstantValueAttribute

a ConstantValue attribute

ofback to summary
public static ConstantValueAttribute of(ConstantDesc value)

Returns a ConstantValue attribute.

Parameters
value:ConstantDesc

the constant value

Returns:ConstantValueAttribute

a ConstantValue attribute