goto 0xa7
Jumps unconditionally.
- Opcode
0xa7(167)- Family
- Branches and switches
- Operands
- 2 bytes: signed branch offset
- Length
- 3 bytes
- Operand stack
… → …- Can throw
- nothing at run time (beyond linking errors)
What it does
Jumps unconditionally, by a signed two-byte offset. javac uses it at the end of loops (back to the test), to skip else-parts, for break and continue, and to jump over exception handlers after a try block.
A backward goto is how the JVM spots a loop: just-in-time compilers count these to decide what to compile.
How often javac uses it
In JDK 25.0.5's java.base module, goto appears 35,040 times in 3,392 of its 7,391 classes: 1.8% of all instructions, the 17th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.<init>, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.fill, java.io.BufferedReader$1.hasNext.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; goto is highlighted.
static boolean same(Integer a, Integer b) in Boxing, compiled by javac 25static { … } in Asserts, compiled by javac 25Related instructions
goto_w Jumps unconditionally (four-byte offset).if_icmpge Pops two ints; jumps if the first is greater than or equal to the second.tableswitch Jumps through a table indexed by an int (dense case values).
Specification: JVMS §6.5, goto (Java SE 25).