---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 27 Edition"
java_version: 27
chapter: "Chapter 4. The class File Format"
section: "4.10.1.9"
heading: "4.10.1.9. Type Checking Instructions"
parent: "4.10.1. Verification by Type Checking"
source: https://docs.oracle.com/javase/specs/jvms/se27/html/jvms-4.html#jvms-4.10.1.9
id: "4.10.1.9"
url: https://jvm.obfuscated.software/jvms/se27/4.10.1.9.html
raw: https://jvm.obfuscated.software/jvms/se27/4.10.1.9.md
---

# 4.10.1.9. Type Checking Instructions

In general, the type rule for an instruction is given relative to an environment `Environment` that defines the class and method in which the instruction occurs ([§4.10.1.1](4.10.1.1.md)), and the offset `Offset` within the method at which the instruction occurs. The rule states that if the incoming type state `StackFrame` fulfills certain requirements, then:

- The instruction is type safe.

- It is provable that the type state after the instruction completes normally has a particular form given by `NextStackFrame`, and that the type state after the instruction completes abruptly is given by `ExceptionStackFrame`.

  The type state after an instruction completes abruptly is the same as the incoming type state, except that the operand stack is empty.

  ```
  exceptionStackFrame(StackFrame, ExceptionStackFrame) :-
      StackFrame = frame(Locals, _OperandStack, Flags),
      ExceptionStackFrame = frame(Locals, [], Flags).
  ```

Many instructions have type rules that are completely isomorphic to the rules for other instructions. If an instruction `b1` is isomorphic to another instruction `b2`, then the type rule for `b1` is the same as the type rule for `b2`.

```
instructionIsTypeSafe(Instruction, Environment, Offset, StackFrame,
                      NextStackFrame, ExceptionStackFrame) :-
    instructionHasEquivalentTypeRule(Instruction, IsomorphicInstruction),
    instructionIsTypeSafe(IsomorphicInstruction, Environment, Offset,
                          StackFrame, NextStackFrame,
                          ExceptionStackFrame).
```

The English language description of each rule is intended to be readable, intuitive, and concise. As such, the description avoids repeating all the contextual assumptions given above. In particular:

- The description does not explicitly mention the environment.
- When the description speaks of the operand stack or local variables in the following, it is referring to the operand stack and local variable components of a type state: either the incoming type state or the outgoing one.
- The type state after the instruction completes abruptly is almost always identical to the incoming type state. The description only discusses the type state after the instruction completes abruptly when that is not the case.
- The description speaks of popping and pushing types onto the operand stack, and does not explicitly discuss issues of stack underflow or overflow. The description assumes these operations can be completed successfully, but the Prolog clauses for operand stack manipulation ensure that the necessary checks are made.
- The description discusses only the manipulation of logical types. In practice, some types take more than one word. The description abstracts from these representation details, but the Prolog clauses that manipulate data do not.

Any ambiguities can be resolved by referring to the formal Prolog clauses.

**Sections:**

- [aaload](4.10.1.9.aaload.md)
- [aastore](4.10.1.9.aastore.md)
- [aconst_null](4.10.1.9.aconst_null.md)
- [aload, aload_<n>](4.10.1.9.aload.md)
- [anewarray](4.10.1.9.anewarray.md)
- [areturn](4.10.1.9.areturn.md)
- [arraylength](4.10.1.9.arraylength.md)
- [astore, astore_<n>](4.10.1.9.astore.md)
- [athrow](4.10.1.9.athrow.md)
- [baload](4.10.1.9.baload.md)
- [bastore](4.10.1.9.bastore.md)
- [bipush](4.10.1.9.bipush.md)
- [caload](4.10.1.9.caload.md)
- [castore](4.10.1.9.castore.md)
- [checkcast](4.10.1.9.checkcast.md)
- [d2f, d2i, d2l](4.10.1.9.d2f.md)
- [dadd](4.10.1.9.dadd.md)
- [daload](4.10.1.9.daload.md)
- [dastore](4.10.1.9.dastore.md)
- [dcmp<op>](4.10.1.9.dcmp_op.md)
- [dconst_<d>](4.10.1.9.dconst_d.md)
- [ddiv](4.10.1.9.ddiv.md)
- [dload, dload_<n>](4.10.1.9.dload.md)
- [dmul](4.10.1.9.dmul.md)
- [dneg](4.10.1.9.dneg.md)
- [drem](4.10.1.9.drem.md)
- [dreturn](4.10.1.9.dreturn.md)
- [dstore, dstore_<n>](4.10.1.9.dstore.md)
- [dsub](4.10.1.9.dsub.md)
- [dup](4.10.1.9.dup.md)
- [dup_x1](4.10.1.9.dup_x1.md)
- [dup_x2](4.10.1.9.dup_x2.md)
- [dup2](4.10.1.9.dup2.md)
- [dup2_x1](4.10.1.9.dup2_x1.md)
- [dup2_x2](4.10.1.9.dup2_x2.md)
- [f2d, f2i, f2l](4.10.1.9.f2d.md)
- [fadd](4.10.1.9.fadd.md)
- [faload](4.10.1.9.faload.md)
- [fastore](4.10.1.9.fastore.md)
- [fcmp<op>](4.10.1.9.fcmp_op.md)
- [fconst_<f>](4.10.1.9.fconst_f.md)
- [fdiv](4.10.1.9.fdiv.md)
- [fload, fload_<n>](4.10.1.9.fload.md)
- [fmul](4.10.1.9.fmul.md)
- [fneg](4.10.1.9.fneg.md)
- [frem](4.10.1.9.frem.md)
- [freturn](4.10.1.9.freturn.md)
- [fstore, fstore_<n>](4.10.1.9.fstore.md)
- [fsub](4.10.1.9.fsub.md)
- [getfield](4.10.1.9.getfield.md)
- [getstatic](4.10.1.9.getstatic.md)
- [goto, goto_w](4.10.1.9.goto.md)
- [i2b, i2c, i2d, i2f, i2l, i2s](4.10.1.9.i2b.md)
- [iadd](4.10.1.9.iadd.md)
- [iaload](4.10.1.9.iaload.md)
- [iand](4.10.1.9.iand.md)
- [iastore](4.10.1.9.iastore.md)
- [iconst_<i>](4.10.1.9.iconst_i.md)
- [idiv](4.10.1.9.idiv.md)
- [if_acmp<cond>](4.10.1.9.if_acmp_cond.md)
- [if_icmp<cond>](4.10.1.9.if_icmp_cond.md)
- [if<cond>](4.10.1.9.if_cond.md)
- [ifnonnull, ifnull](4.10.1.9.ifnonnull.md)
- [iinc](4.10.1.9.iinc.md)
- [iload, iload_<n>](4.10.1.9.iload.md)
- [imul](4.10.1.9.imul.md)
- [ineg](4.10.1.9.ineg.md)
- [instanceof](4.10.1.9.instanceof.md)
- [invokedynamic](4.10.1.9.invokedynamic.md)
- [invokeinterface](4.10.1.9.invokeinterface.md)
- [invokespecial](4.10.1.9.invokespecial.md)
- [invokestatic](4.10.1.9.invokestatic.md)
- [invokevirtual](4.10.1.9.invokevirtual.md)
- [ior, irem](4.10.1.9.ior.md)
- [ireturn](4.10.1.9.ireturn.md)
- [ishl, ishr, iushr](4.10.1.9.ishl.md)
- [istore, istore_<n>](4.10.1.9.istore.md)
- [isub, ixor](4.10.1.9.isub.md)
- [l2d, l2f, l2i](4.10.1.9.l2d.md)
- [ladd](4.10.1.9.ladd.md)
- [laload](4.10.1.9.laload.md)
- [land](4.10.1.9.land.md)
- [lastore](4.10.1.9.lastore.md)
- [lcmp](4.10.1.9.lcmp.md)
- [lconst_<l>](4.10.1.9.lconst_l.md)
- [ldc, ldc_w, ldc2_w](4.10.1.9.ldc.md)
- [ldiv](4.10.1.9.ldiv.md)
- [lload, lload_<n>](4.10.1.9.lload.md)
- [lmul](4.10.1.9.lmul.md)
- [lneg](4.10.1.9.lneg.md)
- [lookupswitch](4.10.1.9.lookupswitch.md)
- [lor, lrem](4.10.1.9.lor.md)
- [lreturn](4.10.1.9.lreturn.md)
- [lshl, lshr, lushr](4.10.1.9.lshl.md)
- [lstore, lstore_<n>](4.10.1.9.lstore.md)
- [lsub, lxor](4.10.1.9.lsub.md)
- [monitorenter, monitorexit](4.10.1.9.monitorenter.md)
- [multianewarray](4.10.1.9.multianewarray.md)
- [new](4.10.1.9.new.md)
- [newarray](4.10.1.9.newarray.md)
- [nop](4.10.1.9.nop.md)
- [pop, pop2](4.10.1.9.pop.md)
- [putfield](4.10.1.9.putfield.md)
- [putstatic](4.10.1.9.putstatic.md)
- [return](4.10.1.9.return.md)
- [saload](4.10.1.9.saload.md)
- [sastore](4.10.1.9.sastore.md)
- [sipush](4.10.1.9.sipush.md)
- [swap](4.10.1.9.swap.md)
- [tableswitch](4.10.1.9.tableswitch.md)
- [wide](4.10.1.9.wide.md)
