---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 14 Edition"
java_version: 14
chapter: "Chapter 6. The Java Virtual Machine Instruction Set"
section: "6.5.ret"
heading: "ret"
parent: "6.5. Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-6.html#jvms-6.5.ret
id: "6.5.ret"
url: https://jvm.obfuscated.software/jvms/se14/6.5.ret.html
raw: https://jvm.obfuscated.software/jvms/se14/6.5.ret.md
---

# ret

## Operation

Return from subroutine

## Format

```
ret
index
```

## Forms

*ret* = 169 (0xa9)

## Operand Stack

No change

## Description

The *index* is an unsigned byte between 0 and 255, inclusive. The local variable at *index* in the current frame ([§2.6](2.6.md)) must contain a value of type `returnAddress`. The contents of the local variable are written into the Java Virtual Machine's `pc` register, and execution continues there.

## Notes

Note that *jsr* ([§*jsr*](6.5.jsr.md)) pushes the address onto the operand stack and *ret* gets it out of a local variable. This asymmetry is intentional.

In Oracle's implementation of a compiler for the Java programming language prior to Java SE 6, the *ret* instruction was used with the *jsr* and *jsr_w* instructions ([§*jsr*](6.5.jsr.md), [§*jsr_w*](6.5.jsr_w.md)) in the implementation of the `finally` clause ([§3.13](3.13.md), [§4.10.2.5](4.10.2.5.md)).

The *ret* instruction should not be confused with the *return* instruction ([§*return*](6.5.return.md)). A *return* instruction returns control from a method to its invoker, without passing any value back to the invoker.

The *ret* opcode can be used in conjunction with the *wide* instruction ([§*wide*](6.5.wide.md)) to access a local variable using a two-byte unsigned index.
