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

public sealed Interface FieldInstruction

extends Instruction
permits BoundFieldInstruction, UnboundFieldInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundFieldInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundFieldInstruction
Imports
java.lang.classfile.CodeBuilder, .CodeElement, .CodeModel, .Instruction, .Opcode, java.lang.classfile.constantpool.ClassEntry, .FieldRefEntry, .NameAndTypeEntry, .Utf8Entry, java.lang.constant.ClassDesc, jdk.internal.classfile.impl.AbstractInstruction, .TemporaryConstantPool, .Util

Models a field access instruction in the code array of a Code attribute. Corresponding opcodes have a kind of Opcode.Kind#FIELD_ACCESS. Delivered as a CodeElement when traversing the elements of a CodeModel.

A field access instruction is composite:

FieldInstruction( Opcode opcode, FieldRefEntry field, )
FieldInstruction(
    Opcode opcode,
    FieldRefEntry field,
)
Since
24
See Also
Opcode.Kind#FIELD_ACCESS, CodeBuilder::fieldAccess

Method Summary

Modifier and TypeMethod and Description
public FieldRefEntry

Returns:

the FieldRefEntry constant described by this instruction
field
()

Returns the FieldRefEntry constant described by this instruction.

public default Utf8Entry

Returns:

the name of the field
name
()

Returns the name of the field.

public static FieldInstruction

Returns:

a field access instruction
of
(Opcode
the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS
op
,
FieldRefEntry
a constant pool entry describing the field
field
)

Returns a field access instruction.

public static FieldInstruction

Returns:

a field access instruction
of
(Opcode
the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS
op
,
ClassEntry
the class holding the field
owner
,
Utf8Entry
the name of the field
name
,
Utf8Entry
the field descriptor
type
)

Returns a field access instruction.

public static FieldInstruction

Returns:

a field access instruction
of
(Opcode
the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS
op
,
ClassEntry
the class holding the field
owner
,
NameAndTypeEntry
the name and field descriptor of the field
nameAndType
)

Returns a field access instruction.

public default ClassEntry

Returns:

the class holding the field
owner
()

Returns the class holding the field.

public default Utf8Entry

Returns:

the field descriptor string of the field
type
()

Returns the field descriptor string of the field.

public default ClassDesc

Returns:

a symbolic descriptor for the type of the field
typeSymbol
()

Returns a symbolic descriptor for the type of the field.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

fieldback to summary
public FieldRefEntry field()

Returns the FieldRefEntry constant described by this instruction.

Returns:FieldRefEntry

the FieldRefEntry constant described by this instruction

nameback to summary
public default Utf8Entry name()

Returns the name of the field.

Returns:Utf8Entry

the name of the field

ofback to summary
public static FieldInstruction of(Opcode op, FieldRefEntry field)

Returns a field access instruction.

Parameters
op:Opcode

the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS

field:FieldRefEntry

a constant pool entry describing the field

Returns:FieldInstruction

a field access instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#FIELD_ACCESS.
ofback to summary
public static FieldInstruction of(Opcode op, ClassEntry owner, Utf8Entry name, Utf8Entry type)

Returns a field access instruction.

Parameters
op:Opcode

the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS

owner:ClassEntry

the class holding the field

name:Utf8Entry

the name of the field

type:Utf8Entry

the field descriptor

Returns:FieldInstruction

a field access instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#FIELD_ACCESS.
ofback to summary
public static FieldInstruction of(Opcode op, ClassEntry owner, NameAndTypeEntry nameAndType)

Returns a field access instruction.

Parameters
op:Opcode

the opcode for the specific type of field access instruction, which must be of kind Opcode.Kind#FIELD_ACCESS

owner:ClassEntry

the class holding the field

nameAndType:NameAndTypeEntry

the name and field descriptor of the field

Returns:FieldInstruction

a field access instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#FIELD_ACCESS.
ownerback to summary
public default ClassEntry owner()

Returns the class holding the field.

Returns:ClassEntry

the class holding the field

typeback to summary
public default Utf8Entry type()

Returns the field descriptor string of the field.

API Note

A symbolic descriptor for the type of the field is available through typeSymbol().

Returns:Utf8Entry

the field descriptor string of the field

typeSymbolback to summary
public default ClassDesc typeSymbol()

Returns a symbolic descriptor for the type of the field.

Returns:ClassDesc

a symbolic descriptor for the type of the field