- All Superinterfaces:
ClassfileElement,CodeElement,Instruction
- All Known Subinterfaces:
ConstantInstruction.ArgumentConstantInstruction,ConstantInstruction.IntrinsicConstantInstruction,ConstantInstruction.LoadConstantInstruction
- All Known Implementing Classes:
AbstractInstruction.BoundArgumentConstantInstruction,AbstractInstruction.BoundLoadConstantInstruction,AbstractInstruction.UnboundArgumentConstantInstruction,AbstractInstruction.UnboundIntrinsicConstantInstruction,AbstractInstruction.UnboundLoadConstantInstruction
public sealed interface ConstantInstruction
extends Instruction
permits ConstantInstruction.IntrinsicConstantInstruction, ConstantInstruction.ArgumentConstantInstruction, ConstantInstruction.LoadConstantInstruction
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. Delivered as a CodeElement when traversing the elements of a CodeModel.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceModels an "argument constant" instruction (e.g.,bipush).static interfaceModels an "intrinsic constant" instruction (e.g.,iconst_0).static interfaceModels a "load constant" instruction (e.g.,ldc). -
Method Summary
Modifier and TypeMethodDescriptionReturns the constant value.ofArgument(Opcode op, int value) Returns an argument constant instruction.ofIntrinsic(Opcode op) Returns an intrinsic constant instruction.ofLoad(Opcode op, LoadableConstantEntry constant) Returns a load constant instruction.typeKind()Returns the type of the constant.Methods inherited from interface org.glavo.classfile.Instruction
opcode, sizeInBytes
-
Method Details
-
constantValue
ConstantDesc constantValue()Returns the constant value.- Returns:
- the constant value
-
typeKind
TypeKind typeKind()Returns the type of the constant.- Returns:
- the type of the constant
-
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- Returns:
- an intrinsic constant instruction
-
ofArgument
Returns an argument constant instruction.- Parameters:
op- the opcode for the specific type of intrinsic constant instruction, which must be of kindOpcode.Kind.CONSTANTvalue- the constant value- Returns:
- an argument constant instruction
-
ofLoad
static ConstantInstruction.LoadConstantInstruction ofLoad(Opcode op, LoadableConstantEntry constant) Returns a load constant instruction.- Parameters:
op- the opcode for the specific type of load constant instruction, which must be of kindOpcode.Kind.CONSTANTconstant- the constant value- Returns:
- a load constant instruction
-