Store object reference in local variable <n>, n=0,1,2,3
Bytecode
Type | Description |
u1 | astore_0 opcode = 0x4B (75) |
u1 | astore_1 opcode = 0x4C (76) |
u1 | astore_2 opcode = 0x4D (77) |
u1 | astore_3 opcode = 0x4E (78) |
Pops objectref (a reference to an object or array) off the stack and stores it in local variable <n>, where <n> is 0, 1, 2 or 3. Each of the astore_<n> instructions is the same as astore with an index of <n>, except that the operand <n> is implicit.
<n> must be a valid local variable number in the current frame. 'astore_<n>' is functionally equivalent to 'astore <n>', although it is typically more efficient and also takes fewer bytes in the bytecode.The <n> must be a valid index into the local variables of the current frame.
The objectref on the top of the operand stack must be of type returnAddress
or of type reference
. It is popped from the operand stack, and the value of
the local variable at <n> is set to objectref.
Example
astore_0 ; store reference in local variable 0
Notes An astore_<n>
instruction is used with an objectref of type returnAddress
. An aload_<n>
instruction cannot be used to load a value of type returnAddress
from a local
variable onto the operand stack. This asymmetry with the corresponding astore_<n>
instruction is intentional.