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.