aload :
retrieve object reference from local variable : index : visitInsn()
- Description
- Retrieves an object reference from a local variable and pushes it onto
the operand stack. The aload instruction takes a single parameter,
<varnum>, an unsigned integer which indicates which local variable to
retrieve. The object reference in that local variable is retrieved and placed
on the stack. <varnum> must be a valid local variable number in the
current frame.
- Example
aload 1 ; push object reference in local variable 1 onto the stack
- Notes
- If you use astore to store a returnAddress in a local variable,
you cannot then use aload to retrieve the value of that local
variable. Instead, if a local variable holds a returnAddress, your only choices
are to (1) use ret to return to that address, or (2) use one of the
store instructions to store some other value in the local variable.
- See also
- fload iload lload dload wide
- Stack
Before
|
After
|
... |
objectref |
|
... |
- Bytecode
Type
|
Description |
u1
|
aload
opcode = 0x19 (25)
|
u1
|
<varnum> |
There
is also a wide format for this instruction, which supports access to
all local variables from 0 to 65535:
Type
|
Description |
u1 |
wide
opcode = 0xC4 (196)
|
u1 |
aload
opcode = 0x19 (25)
|
u2 |
<varnum> |