---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 22 Edition"
java_version: 22
chapter: "Chapter 2. The Structure of the Java Virtual Machine"
section: "2.11"
heading: "2.11. Instruction Set Summary"
parent: "Chapter 2. The Structure of the Java Virtual Machine"
source: https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-2.html#jvms-2.11
id: "2.11"
url: https://jvm.obfuscated.software/jvms/se22/2.11.html
raw: https://jvm.obfuscated.software/jvms/se22/2.11.md
---

# 2.11. Instruction Set Summary

A Java Virtual Machine instruction consists of a one-byte *opcode* specifying the operation to be performed, followed by zero or more *operands* supplying arguments or data that are used by the operation. Many instructions have no operands and consist only of an opcode.

Ignoring exceptions, the inner loop of a Java Virtual Machine interpreter is effectively

```
do {
    atomically calculate pc and fetch opcode at pc;
    if (operands) fetch operands;
    execute the action for the opcode;
} while (there is more to do);
```

The number and size of the operands are determined by the opcode. If an operand is more than one byte in size, then it is stored in *big-endian* order - high-order byte first. For example, an unsigned 16-bit index into the local variables is stored as two unsigned bytes, *byte1* and *byte2*, such that its value is (*byte1* `<<` 8) | *byte2*.

The bytecode instruction stream is only single-byte aligned. The two exceptions are the *lookupswitch* and *tableswitch* instructions ([§*lookupswitch*](6.5.lookupswitch.md), [§*tableswitch*](6.5.tableswitch.md)), which are padded to force internal alignment of some of their operands on 4-byte boundaries.

The decision to limit the Java Virtual Machine opcode to a byte and to forgo data alignment within compiled code reflects a conscious bias in favor of compactness, possibly at the cost of some performance in naive implementations. A one-byte opcode also limits the size of the instruction set. Not assuming data alignment means that immediate data larger than a byte must be constructed from bytes at run time on many machines.

**Sections:**

- [2.11.1. Types and the Java Virtual Machine](2.11.1.md)
- [2.11.2. Load and Store Instructions](2.11.2.md)
- [2.11.3. Arithmetic Instructions](2.11.3.md)
- [2.11.4. Type Conversion Instructions](2.11.4.md)
- [2.11.5. Object Creation and Manipulation](2.11.5.md)
- [2.11.6. Operand Stack Management Instructions](2.11.6.md)
- [2.11.7. Control Transfer Instructions](2.11.7.md)
- [2.11.8. Method Invocation and Return Instructions](2.11.8.md)
- [2.11.9. Throwing Exceptions](2.11.9.md)
- [2.11.10. Synchronization](2.11.10.md)
