return 0xb1

Returns from a void method.

Opcode
0xb1 (177)
Family
Returns
Operands
none
Length
1 byte
Operand stack
… → …, (empty: the frame is gone)
Can throw
IllegalMonitorStateException

What it does

Returns from a void method, a constructor or a static initialiser. javac adds one at the end of a void method even when the source has no return statement.

The IllegalMonitorStateException is for a synchronized method whose monitor is no longer held, which javac never produces.

How often javac uses it

In JDK 25.0.5's java.base module, return appears 21,097 times in 6,523 of its 7,391 classes: 1.1% of all instructions, the 28th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.ensureOpen, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.<init>, java.io.BufferedReader$1.<init>.

Examples

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; return is highlighted.

public Tour() in Tour, compiled by javac 25
3public class Tour {
0aload_0 // this
1invokespecial #1// new Object()

Open in the viewer

public Asserts() in Asserts, compiled by javac 25
2public class Asserts {
0aload_0 // this
1invokespecial #1// new Object()

Open in the viewer

Related instructions

ireturn Returns the int on top of the stack from the method.areturn Returns the reference on top of the stack from the method.athrow Throws the exception on top of the stack.

Specification: JVMS §6.5, return (Java SE 25).