- All Superinterfaces:
ClassFileElementPREVIEW
,CodeElementPREVIEW
,InstructionPREVIEW
- All Known Subinterfaces:
ConstantInstruction.ArgumentConstantInstructionPREVIEW
,ConstantInstruction.IntrinsicConstantInstructionPREVIEW
,ConstantInstruction.LoadConstantInstructionPREVIEW
public sealed interface ConstantInstruction
extends InstructionPREVIEW
permits ConstantInstruction.IntrinsicConstantInstructionPREVIEW, ConstantInstruction.ArgumentConstantInstructionPREVIEW, ConstantInstruction.LoadConstantInstructionPREVIEW
ConstantInstruction
is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a constant-load instruction in the
code
array of a
Code
attribute, including "intrinsic constant" instructions (e.g.,
iconst_0
), "argument constant" instructions (e.g., bipush
), and "load
constant" instructions (e.g., LDC
). Corresponding opcodes will have
a kind
of Opcode.Kind.CONSTANT
PREVIEW. Delivered as a CodeElement
PREVIEW when traversing the elements of a CodeModel
PREVIEW.- Since:
- 22
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Preview.Models an "argument constant" instruction (e.g.,bipush
).static interface
Preview.Models an "intrinsic constant" instruction (e.g.,iconst_0
).static interface
Preview.Models a "load constant" instruction (e.g.,ldc
). -
Method Summary
Modifier and TypeMethodDescriptionReturns the constant value.ofArgument
(OpcodePREVIEW op, int value) Returns an argument constant instruction.Returns an intrinsic constant instruction.ofLoad
(OpcodePREVIEW op, LoadableConstantEntryPREVIEW constant) Returns a load constant instruction.typeKind()
Returns the type of the constant.Methods declared in interface java.lang.classfile.InstructionPREVIEW
opcode, sizeInBytes
-
Method Details
-
constantValue
-
typeKind
-
ofIntrinsic
Returns an intrinsic constant instruction.- Parameters:
op
- the opcode for the specific type of intrinsic constant instruction, which must be of kindOpcode.Kind.CONSTANT
PREVIEW- Returns:
- an intrinsic constant instruction
-
ofArgument
static ConstantInstruction.ArgumentConstantInstructionPREVIEW ofArgument(OpcodePREVIEW op, int value) Returns an argument constant instruction.- Parameters:
op
- the opcode for the specific type of intrinsic constant instruction, which must be of kindOpcode.Kind.CONSTANT
PREVIEWvalue
- the constant value- Returns:
- an argument constant instruction
-
ofLoad
static ConstantInstruction.LoadConstantInstructionPREVIEW ofLoad(OpcodePREVIEW op, LoadableConstantEntryPREVIEW constant) Returns a load constant instruction.- Parameters:
op
- the opcode for the specific type of load constant instruction, which must be of kindOpcode.Kind.CONSTANT
PREVIEWconstant
- the constant value- Returns:
- a load constant instruction
-
ConstantInstruction
when preview features are enabled.