Interface TypeCheckInstruction
- All Superinterfaces:
ClassFileElement, CodeElement, Instruction
public sealed interface TypeCheckInstruction extends Instruction
instanceof or a checkcast instruction in the code array of a Code attribute. Corresponding opcodes have a kind of Opcode.Kind.TYPE_CHECK. Delivered as a CodeElement when traversing the elements of a CodeModel. An instanceof checks the type and pushes an integer to the operand stack. A checkcast checks the type and throws a ClassCastException if the check fails. instanceof treat the null reference as a failure, while checkcast treat the null reference as a success.
A type check instruction is composite:
TypeCheckInstruction(
Opcode opcode,
ClassEntry type
)
- Since:
- 24
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
static TypeCheckInstruction |
of |
Returns a type check instruction. |
static TypeCheckInstruction |
of |
Returns a type check instruction. |
ClassEntry |
type() |
Returns the type against which the instruction checks. |
Methods declared in interface Instruction
opcode, sizeInBytes
Method Details
type
ClassEntry type()
- Returns:
- the type against which the instruction checks
of
static TypeCheckInstruction of(Opcode op, ClassEntry type)
- Parameters:
-
op- the opcode for the specific type of type check instruction, which must be of kindOpcode.Kind.TYPE_CHECK -
type- the type against which to check or cast - Returns:
- a type check instruction
- Throws:
-
IllegalArgumentException- if the opcode kind is notOpcode.Kind.TYPE_CHECK
of
static TypeCheckInstruction of(Opcode op, ClassDesc type)
- Parameters:
-
op- the opcode for the specific type of type check instruction, which must be of kindOpcode.Kind.TYPE_CHECK -
type- the type against which to check or cast - Returns:
- a type check instruction
- Throws:
-
IllegalArgumentException- if the opcode kind is notOpcode.Kind.TYPE_CHECK, or iftypeis primitive
© 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.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/instruction/TypeCheckInstruction.html