Top Description Methods
java.lang.classfile.instruction

public sealed Interface FieldInstruction

extends Instruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundFieldInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundFieldInstruction
Annotations
@PreviewFeature
feature:CLASSFILE_API
Imports
java.lang.constant.ClassDesc, java.lang.classfile.CodeElement, .CodeModel, .Instruction, .Opcode, java.lang.classfile.constantpool.ClassEntry, .FieldRefEntry, .NameAndTypeEntry, .Utf8Entry, jdk.internal.classfile.impl.AbstractInstruction, .TemporaryConstantPool, .Util, jdk.internal.javac.PreviewFeature

Preview

Second Preview of ClassFile API (JEP 466).

Programs can only use FieldInstruction when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

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

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 of the field
type
()

Returns the field descriptor 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

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

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 of the field.

Returns:Utf8Entry

the field descriptor 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