---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 8 Edition"
java_version: 8
chapter: "Chapter 6. The Java Virtual Machine Instruction Set"
section: "6.5.aastore"
heading: "aastore"
parent: "6.5. Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.aastore
id: "6.5.aastore"
url: https://jvm.obfuscated.software/jvms/se8/6.5.aastore.html
raw: https://jvm.obfuscated.software/jvms/se8/6.5.aastore.md
---

# aastore

## Operation

Store into `reference` array

## Format

```
aastore
```

## Forms

*aastore* = 83 (0x53)

## Operand 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 `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*.

At run time, the type of *value* must be compatible with the type of the components of the array referenced by *arrayref*. Specifically, assignment of a value of reference type S (source) to an array component of reference type T (target) is allowed only if:

- 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 S is an interface type, then:

  - If T is a class type, then T must be `Object`.
  - If T is an interface type, then T must be the same interface as S or a superinterface of S.

- If S is an array type, namely, the type SC`[]`, that is, an array of components of type SC, then:

  - If T is a class type, then T must be `Object`.

  - If T is an interface type, then T must be one of the interfaces implemented by arrays (JLS §4.10.3).

  - If T is an array type TC`[]`, that is, an array of components of type TC, then one of the following must be true:

    - TC and SC are the same primitive type.
    - TC and SC are reference types, and type SC is assignable to TC by these run-time rules.

## Run-time 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 (JLS §5.2) with the actual type of the components of the array, *aastore* throws an `ArrayStoreException`.
