Load an object reference from an array
Bytecode
Type | Description |
u1 | aaload opcode = 0x32 (50) |
Stack ..., arrayref, index ==> ..., value
Retrieves an object reference from an array of objects and places it on the stack.
The arrayref must be of type reference
and must refer to an array
whose components are of type reference
.
The index must be of type int
.
Both arrayref and index are popped from the operand stack. The reference
value in the component of the array at index is retrieved and pushed onto
the top of the operand stack.
Example
This is like the Java code:
; Object x = arr[0];
; where x is local variable 2 and arr is an array of objects in local variable 1
aload_1 ; load local variable 1 onto the stack
iconst_0 ; push the integer 0 onto the stack
aaload ; retrieve the entry
astore_2 ; store the entry in local variable 2
Exceptions
NullPointerException
- arrayref is null
ArrayIndexOutOfBoundsException
- index is < 0 or >= arrayref.length