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

public sealed Interface TypeCheckInstruction

extends Instruction
permits BoundTypeCheckInstruction, UnboundTypeCheckInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundTypeCheckInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundTypeCheckInstruction
Imports
java.lang.classfile.CodeElement, .CodeModel, .Instruction, .Opcode, java.lang.classfile.constantpool.ClassEntry, java.lang.constant.ClassDesc, jdk.internal.classfile.impl.AbstractInstruction, .TemporaryConstantPool, .Util

Models an 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 )
TypeCheckInstruction(
    Opcode opcode,
    ClassEntry type
)
Since
24

Method Summary

Modifier and TypeMethod and Description
public static TypeCheckInstruction

Returns:

a type check instruction
of
(Opcode
the opcode for the specific type of type check instruction, which must be of kind Opcode.Kind#TYPE_CHECK
op
,
ClassEntry
the type against which to check or cast
type
)

Returns a type check instruction.

public static TypeCheckInstruction

Returns:

a type check instruction
of
(Opcode
the opcode for the specific type of type check instruction, which must be of kind Opcode.Kind#TYPE_CHECK
op
,
ClassDesc
the type against which to check or cast
type
)

Returns a type check instruction.

public ClassEntry

Returns:

the type against which the instruction checks
type
()

Returns the type against which the instruction checks.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

ofback to summary
public static TypeCheckInstruction of(Opcode op, ClassEntry type)

Returns a type check instruction.

Parameters
op:Opcode

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

type:ClassEntry

the type against which to check or cast

Returns:TypeCheckInstruction

a type check instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#TYPE_CHECK
ofback to summary
public static TypeCheckInstruction of(Opcode op, ClassDesc type)

Returns a type check instruction.

Parameters
op:Opcode

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

type:ClassDesc

the type against which to check or cast

Returns:TypeCheckInstruction

a type check instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#TYPE_CHECK, or if type is primitive
typeback to summary
public ClassEntry type()

Returns the type against which the instruction checks.

Returns:ClassEntry

the type against which the instruction checks