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

# getstatic

## Operation

Get `static` field from class

## Format

```
getstatic
indexbyte1
indexbyte2
```

## Forms

*getstatic* = 178 (0xb2)

## Operand Stack

..., →

..., *value*

## Description

The unsigned *indexbyte1* and *indexbyte2* are used to construct an index into the run-time constant pool of the current class ([§2.6](2.6.md)), where the value of the index is (*indexbyte1* `<<` 8) | *indexbyte2*. The run-time constant pool entry at the index must be a symbolic reference to a field ([§5.1](5.1.md)), which gives the name and descriptor of the field as well as a symbolic reference to the class or interface in which the field is to be found. The referenced field is resolved ([§5.4.3.2](5.4.3.2.md)).

On successful resolution of the field, the class or interface that declared the resolved field is initialized if that class or interface has not already been initialized ([§5.5](5.5.md)).

The *value* of the class or interface field is fetched and pushed onto the operand stack.

## Linking Exceptions

During resolution of the symbolic reference to the class or interface field, any of the exceptions pertaining to field resolution ([§5.4.3.2](5.4.3.2.md)) can be thrown.

Otherwise, if the resolved field is not a `static` (class) field or an interface field, *getstatic* throws an `IncompatibleClassChangeError`.

## Run-time Exception

Otherwise, if execution of this *getstatic* instruction causes initialization of the referenced class or interface, *getstatic* may throw an `Error` as detailed in [§5.5](5.5.md).
