Return from method with the object reference result
Bytecode
Type | Description |
u1 | areturn opcode = 0xB0 (176) |
Stack ..., objectref ==> [empty]
The objectref must be of type reference
and must refer to an object
of a type that is assignment compatible with the type represented by the return
descriptor of the returning method. The objectref is popped from the operand stack
of the current frame and pushed onto the operand stack of the frame of the invoker. Any
other values on the operand stack of the current method are discarded. If the returning
method is a synchronized
method, the monitor acquired or reentered on
invocation of the method is released or exited (respectively) as if by execution of a monitorexit
instruction.
The interpreter then reinstates the frame of the invoker and returns control to the invoker.
Example
; This method takes an integer parameter n, and returns a new array of ints of length n.
.method public static makeIntArray(I)[I
aload_0 ; push the array size
(i.e. n) parameter onto the stack
newarray int ; make the array
areturn ; return
the array
.endmethod
; an example of calling makeIntArray to make a 10 element array of ints:
bipush 10
invokestatic Example/makeIntArray(I)[I
astore_1 ; store array in local variable 1