Spec-Zone.ru › OpenJDK 27

Interface ConstantInstruction

All Superinterfaces:
ClassFileElement, CodeElement, Instruction
All Known Subinterfaces:
ConstantInstruction.ArgumentConstantInstruction, ConstantInstruction.IntrinsicConstantInstruction, ConstantInstruction.LoadConstantInstruction
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", "argument", and "load" constant instructions. Corresponding opcodes have a kind of Opcode.Kind.CONSTANT. Delivered as a CodeElement when traversing the elements of a CodeModel.

The loaded constant value is symbolically represented as a ConstantDesc:

ConstantInstruction(ConstantDesc constantValue)
Sealed Class Hierarchy Graph:
Sealed class hierarchy graph for ConstantInstructionSealed class hierarchy graph for ConstantInstruction
Since:
24
See Also:
  • Opcode.Kind.CONSTANT
  • CodeBuilder::loadConstant

Nested Class Summary

Modifier and Type Interface Description
static interface  ConstantInstruction.ArgumentConstantInstruction
Models an "argument constant" instruction, which encodes the constant value in the instruction directly.
static interface  ConstantInstruction.IntrinsicConstantInstruction
Models an "intrinsic constant" instruction, which encodes the constant value in its opcode.
static interface  ConstantInstruction.LoadConstantInstruction
Models a "load constant" instruction, which encodes the constant value in the constant pool.

Method Summary

Modifier and Type Method Description
ConstantDesc constantValue()
Returns the constant value.
static ConstantInstruction.ArgumentConstantInstruction ofArgument(Opcode op, int value)
Returns an argument constant instruction.
static ConstantInstruction.IntrinsicConstantInstruction ofIntrinsic(Opcode op)
Returns an intrinsic constant instruction.
static ConstantInstruction.LoadConstantInstruction ofLoad(Opcode op, LoadableConstantEntry constant)
Returns a load constant instruction.
TypeKind typeKind()
Returns the computational type of the constant.

Methods declared in interface Instruction

opcode, sizeInBytes
Modifier and Type Method Description
Opcode opcode()
Returns the operation of this instruction.
int sizeInBytes()
Returns the size in bytes of this instruction.

Method Details

constantValue

ConstantDesc constantValue()
Returns the constant value.
Returns:
the constant value

typeKind

TypeKind typeKind()
Returns the computational type of the constant. This is derived from the constantValue.
Returns:
the computational type of the constant

ofIntrinsic

static ConstantInstruction.IntrinsicConstantInstruction ofIntrinsic(Opcode op)
Returns an intrinsic constant instruction.
Parameters:
op - the opcode for the specific type of intrinsic constant instruction, which must be of kind Opcode.Kind.CONSTANT
Returns:
an intrinsic constant instruction
Throws:
IllegalArgumentException - if the opcode does not represent a constant with implicit value

ofArgument

static ConstantInstruction.ArgumentConstantInstruction ofArgument(Opcode op, int value)
Returns an argument constant instruction.

value must be in the range of byte, [-128, 127], for Opcode.BIPUSH, and in the range of short, [-32768, 32767], for Opcode.SIPUSH.

Parameters:
op - the opcode for the specific type of argument constant instruction, which must be Opcode.BIPUSH or Opcode.SIPUSH
value - the constant value
Returns:
an argument constant instruction
Throws:
IllegalArgumentException - if the opcode is not Opcode.BIPUSH or Opcode.SIPUSH, or if the constant value is out of range for the opcode

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 kind Opcode.Kind.CONSTANT
constant - the constant value
Returns:
a load constant instruction
Throws:
IllegalArgumentException - if the opcode is not Opcode.LDC, Opcode.LDC_W, or Opcode.LDC2_W

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API