---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 22 Edition"
java_version: 22
chapter: "Chapter 4. The class File Format"
section: "4.10.1.9.astore"
heading: "astore, astore_<n>"
parent: "4.10.1.9. Type Checking Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html#jvms-4.10.1.9.astore
id: "4.10.1.9.astore"
url: https://jvm.obfuscated.software/jvms/se22/4.10.1.9.astore.html
raw: https://jvm.obfuscated.software/jvms/se22/4.10.1.9.astore.md
---

# astore, astore\_\<n>

An *astore* instruction with operand `Index` is type safe and yields an outgoing type state `NextStackFrame`, if a store instruction with operand `Index` and type `reference` is type safe and yields an outgoing type state `NextStackFrame`.

```
instructionIsTypeSafe(astore(Index), Environment, _Offset, StackFrame,
                      NextStackFrame, ExceptionStackFrame) :-
    storeIsTypeSafe(Environment, Index, reference, StackFrame, NextStackFrame),
    exceptionStackFrame(StackFrame, ExceptionStackFrame).
```

The instructions *astore\_\<n>*, for 0 ≤ *n* ≤ 3, are type safe iff the equivalent *astore* instruction is type safe.

```
instructionHasEquivalentTypeRule(astore_0, astore(0)).
instructionHasEquivalentTypeRule(astore_1, astore(1)).
instructionHasEquivalentTypeRule(astore_2, astore(2)).
instructionHasEquivalentTypeRule(astore_3, astore(3)).
```
