astore <varnum>
or
wide
astore <varnum>
In the first form, <varnum> is an unsigned integer in the range 0 to 0xFF. In the second (wide) form, <varnum> is an unsigned integer in the range 0 to 0xFFFF.
Stack
|
B
efore
|
After
|
|
objectref
|
...
|
|
...
|
|
Pops objectref (a reference to an object or array) off the stack and stores it in local variable <varnum>. The astore instruction takes a single parameter, <varnum>, an unsigned integer which indicates which local variable is used. <varnum> must be a valid local variable number in the current frame.
Example
aload 1 ; Push object reference in local variable 1 onto stack astore 3 ; and store it in local variable 3Bytecode
For local variable
|
Type
|
Description
|
|
u1
|
astore opcode = 0x3A (58)
|
|
u1
|
<varnum>
|
|
Type
|
Description
|
|
u1
|
wide opcode = 0xC4 (196)
|
|
u1
|
astore opcode = 0x3A (58)
|
|
u2
|
<varnum>
|
lstore , istore , dstore , fstore , wide
Notes
astore can also be used to store a returnAddress in a local variable. See the jsr instruction for more details.
baloadStack
|
B
efore
|
After
|
|
index
|
value
|
|
arrayref
|
...
|
|
...
|
...
|
Retrieves a byte from a byte array, expands it to an integer and places it on the operand stack.
arrayref
is a reference to an array of bytes.
index
is an int. The
arrayref
and
index
are removed from the stack, and the 8-bit signed byte at the given
index
in the array is retrieved, sign-extended to a 32-bit int, and
baload is also used to retrieve values from boolean arrays. In this case,
arrayref
is a reference to an array of booleans (see the
Example
; This is like the Java code: ; byte x = arr[0]; ; where x is local variable 2 and arr is a byte array in local variable 1 aload_1 ; load local variable 1 onto the stack iconst_0 ; push the integer 0 onto the stack baload ; retrieve the entry istore_2 ; store the entry in local variable 2Exceptions
NullPointerException - arrayref is null
ArrayIndexOutOfBoundsException - index is < 0 or >= arrayref.length
Bytecode
|
Type
|
Description
|
|
u1
|
baload opcode = 0x33 (51)
|