==== 7.5.2 aastore ==== Store into reference array Format aastore Forms aastore = 55 (0x37) Stack ..., arrayref, index, value -> ... Description 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 short and the 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. At runtime the type of value must be confirmed to be assignment compatible with the type of the components of the array referenced by arrayref. 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 of the operations defined on type T. The detailed rules follow: *If S is a class type, then: *If T is a class type, then S must be the same class as T, or S must be a subclass of T; *If T is an interface type, then S must implement interface T. *If T is a class type, then T must be Object ([[2.2.2.4_Classes| Section 2.2.2.4, Classes]]); *If T is an interface type, T must be the same interface as S or a superinterface of S. *If T is a class type, then T must be Object. *If T is an array type, namely the type TC[], an array of components of type TC, then one of the following must be true: TC and SC are the same primitive type ([[3.1_Data Types and Values| Section 3.1, Data Types and Values]]"). TC and SC are reference types[[3.1_Data Types and Values| Section 3.1, Data Types and Values]]) with type SC assignable to TC, by these rules. *If T is an interface type, T must be one of the interfaces implemented by arrays. Runtime Exceptions If arrayref is null, aastore throws a NullPointerException. Otherwise, if index is not within the bounds of the array referenced by arrayref, the aastore instruction throws an ArrayIndexOutOfBoundsException. Otherwise, if arrayref is not null and the actual type of value is not assignment compatible with the actual type of the component of the array, aastore throws an ArrayStoreException. Notes In some circumstances, the aastore instruction may throw a SecurityException if the current context ([[3.4_Contexts| Section 3.4, Contexts]]) is not the owning context ([[3.4_Contexts| Section 3.4, Contexts]]) of the array referenced by arrayref. The exact circumstances when the exception will be thrown are specified in Chapter 6 of the **//Runtime Environment Specification, Java Card Platform, Version 2.2.2//**.