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

# astore

## Operation

Store `reference` into local variable

## Format

```
astore
index
```

## Forms

*astore* = 58 (0x3a)

## Operand Stack

..., *objectref* →

...

## Description

The *index* is an unsigned byte that must be an index into the local variable array of the current frame ([§2.6](2.6.md)). The *objectref* on the top of the operand stack must be of type `returnAddress` or of type `reference`. It is popped from the operand stack, and the value of the local variable at *index* is set to *objectref*.

## Notes

The *astore* instruction is used with an *objectref* of type `returnAddress` when implementing the `finally` clause of the Java programming language ([§3.13](3.13.md)).

The *aload* instruction ([§*aload*](6.5.aload.md)) cannot be used to load a value of type `returnAddress` from a local variable onto the operand stack. This asymmetry with the *astore* instruction is intentional.

The *astore* opcode can be used in conjunction with the *wide* instruction ([§*wide*](6.5.wide.md)) to access a local variable using a two-byte unsigned index.
