Store an object reference into an array
Bytecode
Type | Description |
u1 | aastore opcode = 0x53 (83) |
Stack ..., arrayref, index, value ==> ...
This instruction stores an object reference into an array of objects.
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
and value must be of type reference
.
The arrayref, index, and value are popped from the operand stack.
The reference
value is stored as the component of the array at index.
The type of value must be assignment compatible with the
type of the components of the array referenced by arrayref. For example, if
the array is declared as an array of Threads, then value must either be null
or an instance of Thread or one of its subclasses. Assignment of a value of
reference type S (source) to a variable of reference type T (target) is allowed only when
the type S supports all the operations defined on type T. The detailed rules follow:
[]
, that is, an array of
components of type SC, then:
S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.
Exceptions
ArrayIndexOutOfBoundsException
- index is < 0 or >= arrayref.length
ArrayStoreException
- value is not compatible with the type of the array
NullPointerException
- arrayref is null