|Contents | Prev | Next | Index||The JavaTM Virtual Machine Specification|
ret = 169 (0xa9)
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
pcregister, and execution continues there.
The ret instruction is used with jsr or jsr_w instructions in the implementation of the
finallyclauses of the Java programming language (see Section 7.13, "Compiling
finally"). Note that jsr pushes the address onto the operand 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 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.
return = 177 (0xb1)
The current method must have return type
void. If the current method is a
synchronizedmethod, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of a monitorexit instruction. If no exception is thrown, any values on the operand stack of the current frame (§3.6) are discarded.
The interpreter then returns control to the invoker of the method, reinstating the frame of the invoker.
If the current method is a
synchronizedmethod and the current thread is not the owner of the monitor acquired or reentered on invocation of the method, return throws an
IllegalMonitorStateException. This can happen, for example, if a
synchronizedmethod contains a monitorexit instruction, but no monitorenter instruction, on the object on which the method is synchronized.
Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in Section 8.13 and if the first of those rules is violated during invocation of the current method, then return throws an
Contents | Prev | Next | Index
The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to [email protected]