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

public sealed Interface StoreInstruction

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

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

A local variable store instruction is composite:

StoreInstruction( TypeKind typeKind, int slot )
StoreInstruction(
    TypeKind typeKind,
    int slot
)
where TypeKind is computational, and slot is u2.

astore series of instructions, or reference type store instructions, can also operate on the returnAddress type from discontinued jump subroutine instructions.

Since
24
See Also
Opcode.Kind#STORE, CodeBuilder::storeLocal

Method Summary

Modifier and TypeMethod and Description
public static StoreInstruction

Returns:

a local variable store instruction
of
(TypeKind
the type of the value to be stored
kind
,
int
the local variable slot to store to
slot
)

Returns a local variable store instruction.

public static StoreInstruction

Returns:

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

Returns a local variable store instruction.

public int

Returns:

the local variable slot to store to
slot
()

Returns the local variable slot to store to.

public TypeKind

Returns:

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

Returns the computational type of the value to be stored.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

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

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

Parameters
kind:TypeKind

the type of the value to be stored

slot:int

the local variable slot to store to

Returns:StoreInstruction

a local variable store instruction

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

Returns a local variable store 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 store instructions when the slot can be encoded with more optimized store instructions.

Parameters
op:Opcode

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

slot:int

the local variable slot to store to

Returns:StoreInstruction

a local variable store instruction

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

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

Returns:int

the local variable slot to store to

typeKindback to summary
public TypeKind typeKind()

Returns the computational type of the value to be stored. The reference type store instructions also operate on the returnAddress type, which does not apply to reference type load instructions.

Returns:TypeKind

the computational type of the value to be stored