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

public sealed Interface IncrementInstruction

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

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

A local variable increment instruction is composite:

IncrementInstruction( int slot, int constant )
IncrementInstruction(
    int slot,
    int constant
)
where
Since
24
Java Virtual Machine Specification
6.5.iinc iinc
See Also
Opcode.Kind#INCREMENT, CodeBuilder::iinc

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the value to increment by
constant
()

Returns the value to increment by.

public static IncrementInstruction

Returns:

an increment instruction
of
(int
the local variable slot to increment
slot
,
int
the value to increment by
constant
)

Returns an increment instruction.

public static IncrementInstruction

Returns:

an increment instruction
of
(Opcode
the opcode for the specific type of increment instruction, which must be of kind Opcode.Kind#INCREMENT
op
,
int
the local variable slot to increment
slot
,
int
the increment constant
constant
)

Returns an increment instruction.

public int

Returns:

the local variable slot to increment
slot
()

Returns the local variable slot to increment.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

constantback to summary
public int constant()

Returns the value to increment by.

Returns:int

the value to increment by

ofback to summary
public static IncrementInstruction of(int slot, int constant)

Returns an increment instruction.

  • slot must be u2.
  • constant must be within [-32768, 32767].
Parameters
slot:int

the local variable slot to increment

constant:int

the value to increment by

Returns:IncrementInstruction

an increment instruction

Exceptions
IllegalArgumentException:
if slot or constant is out of range
ofback to summary
public static IncrementInstruction of(Opcode op, int slot, int constant)

Returns an increment instruction.

slot must be u1 and constant must be within [-128, 127] for iinc, or slot must be u2 and constant must be within [-32768, 32767] for wide iinc.

API Note

The explicit op argument allows creating wide or regular increment instructions when slot and constant can be encoded with more optimized increment instructions.

Parameters
op:Opcode

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

slot:int

the local variable slot to increment

constant:int

the increment constant

Returns:IncrementInstruction

an increment instruction

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

Returns the local variable slot to increment.

Returns:int

the local variable slot to increment