47.

prev next contents
areturn

return from method with object reference result

Jasmin Syntax
     areturn 
Stack

Before

After
objectref
n/a
...

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 
Bytecode

Type

Description
u1
areturn opcode = 0xB0 (176)
See Also

lreturn, freturn, dreturn, ireturn, return, invokevirtual, invokespecial, invokestatic, invokeinterface


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates


Java Virtual Machine
Java Virtual Machine (Java Series)
ISBN: 1565921941
EAN: 2147483647
Year: 1996
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net