areturn : return from method with object reference result : index : visitInsn()

Description
objectref is a reference to an object. It must be assignment compatible with the return type of the current method (See Chapter 7 for details of assignment compatibility). areturn pops objectref off the stack and pushes it onto the operand stack of the invoker (i.e. the method which used invokevirtual, invokespecial, invokestatic or invokeinterface to call the currently executing method). All other items on the current method's operand stack are discarded. If the current method is marked as synchronized, then an implicit monitorexit instruction is executed. Then the current method's frame is discarded, the invoker's frame is reinstated, and control returns to the invoker.
Example
.class Example
.super java/lang/Object
; 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
See also
lreturn freturn dreturn ireturn return invokevirtual invokespecial invokestatic invokeinterface
Stack
Before After
objectref n/a
... ...
Bytecode
Type Description
u1 areturn opcode = 0xB0 (176)