Contents | Prev | Next | Index

ret

Operation
Return from subroutine

ret
index

Forms
ret = 169 (0xa9)

Stack
No change

Description
The index is an unsigned byte between 0 and 255, inclusive. The local variable at index in the current frame (§3.6) 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
The ret instruction is used with jsr or jsr_w instructions in the implementation of the finally keyword of the Java language (see Section 7.13, "Compiling finally"). Note that jsr pushes the address onto the stack and ret gets it out of a local variable. This asymmetry is intentional.

The ret instruction should not be confused with the return instruction. A return instruction returns control from a Java method to its invoker, without passing any value back to the invoker.

The ret opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


Contents | Prev | Next | Index

Java Virtual Machine Specification (HTML generated by dkramer on February 25, 1997)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com