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

public sealed Interface LoadInstruction

extends Instruction
permits BoundLoadInstruction, UnboundLoadInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundLoadInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundLoadInstruction
Imports
java.lang.classfile.CodeBuilder, .CodeElement, .CodeModel, .Instruction, .Opcode, .TypeKind, jdk.internal.classfile.impl.AbstractInstruction, .BytecodeHelpers, .Util

Models a local variable load instruction in the code array of a Code attribute. Corresponding opcodes have a kind of Opcode.Kind#LOAD. Delivered as a CodeElement when traversing the elements of a CodeModel.

A local variable load instruction is composite:

LoadInstruction( TypeKind typeKind, int slot )
LoadInstruction(
    TypeKind typeKind,
    int slot
)
where TypeKind is computational, and slot is u2.
Since
24
See Also
Opcode.Kind#LOAD, CodeBuilder::loadLocal

Method Summary

Modifier and TypeMethod and Description
public static LoadInstruction

Returns:

a local variable load instruction
of
(TypeKind
the type of the value to be loaded
kind
,
int
the local variable slot to load from
slot
)

Returns a local variable load instruction.

public static LoadInstruction

Returns:

a local variable load instruction
of
(Opcode
the opcode for the specific type of load instruction, which must be of kind Opcode.Kind#LOAD
op
,
int
the local variable slot to load from
slot
)

Returns a local variable load instruction.

public int

Returns:

the local variable slot to load from
slot
()

Returns the local variable slot to load from.

public TypeKind

Returns:

the computational type of the value to be loaded
typeKind
()

Returns the computational type of the value to be loaded.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

ofback to summary
public static LoadInstruction of(TypeKind kind, int slot)

Returns a local variable load instruction. kind is converted to its computational type. slot must be a u2 value.

Parameters
kind:TypeKind

the type of the value to be loaded

slot:int

the local variable slot to load from

Returns:LoadInstruction

a local variable load instruction

Exceptions
IllegalArgumentException:
if kind is void or slot is not u2
ofback to summary
public static LoadInstruction of(Opcode op, int slot)

Returns a local variable load instruction.

The range of slot is restricted by the op and its size:

  • If op has size 1, slot must be exactly the slot value implied by the opcode.
  • If op has size 2, slot must be u1.
  • If op has size 4, slot must be u2.

API Note

The explicit op argument allows creating wide or regular load instructions when the slot can be encoded with more optimized load instructions.

Parameters
op:Opcode

the opcode for the specific type of load instruction, which must be of kind Opcode.Kind#LOAD

slot:int

the local variable slot to load from

Returns:LoadInstruction

a local variable load instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#LOAD or slot is out of range
slotback to summary
public int slot()

Returns the local variable slot to load from. It is a u2 value.

Returns:int

the local variable slot to load from

typeKindback to summary
public TypeKind typeKind()

Returns the computational type of the value to be loaded.

Returns:TypeKind

the computational type of the value to be loaded