# Interface TypeCheckInstruction

All Superinterfaces:
  `ClassFileElement, CodeElement, Instruction`

public sealed interface TypeCheckInstruction extends Instruction
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
    )

Since:
  24

## Method Summary

Modifier and Type
Method
Description
`static TypeCheckInstruction`
`of(Opcode op, ClassEntry type)`
Returns a type check instruction.
`static TypeCheckInstruction`
`of(Opcode op, ClassDesc type)`
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.

Returns:
  the type against which the instruction checks

### of

static TypeCheckInstruction of(Opcode op, ClassEntry type)
Returns a type check instruction.

Parameters:
  `op` - the opcode for the specific type of type check instruction, which must be of kind `Opcode.Kind.TYPE_CHECK`
  `type` - the type against which to check or cast
Returns:
  a type check instruction
Throws:
  `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.TYPE_CHECK`

### of

static TypeCheckInstruction of(Opcode op, ClassDesc type)
Returns a type check instruction.

Parameters:
  `op` - the opcode for the specific type of type check instruction, which must be of kind `Opcode.Kind.TYPE_CHECK`
  `type` - the type against which to check or cast
Returns:
  a type check instruction
Throws:
  `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.TYPE_CHECK`, or if `type` is primitive