---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 16 Edition"
java_version: 16
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/se16/html/jvms-6.html#jvms-6.5.aastore
id: "6.5.aastore"
url: https://jvm.obfuscated.software/jvms/se16/6.5.aastore.html
raw: https://jvm.obfuscated.software/jvms/se16/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.

If *value* is `null`, then *value* is stored as the component of the array at *index*.

Otherwise, *value* is non-`null`. If the type of *value* is assignment compatible with the type of the components of the array referenced by *arrayref*, then *value* is stored as the component of the array at *index*.

The following rules are used to determine whether a *value* that is not `null` is assignment compatible with the array component type. If S is the type of the object referred to by *value*, and T is the reference type of the array components, then *aastore* determines whether assignment is compatible as follows:

- 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 array 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 the non-`null` *value* is not assignment compatible with the actual type of the components of the array, *aastore* throws an `ArrayStoreException`.
