---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 10 Edition"
java_version: 10
chapter: "Chapter 5. Loading, Linking, and Initializing"
section: "5.4.3.2"
heading: "5.4.3.2. Field Resolution"
parent: "5.4.3. Resolution"
source: https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-5.html#jvms-5.4.3.2
id: "5.4.3.2"
url: https://jvm.obfuscated.software/jvms/se10/5.4.3.2.html
raw: https://jvm.obfuscated.software/jvms/se10/5.4.3.2.md
---

# 5.4.3.2. Field Resolution

To resolve an unresolved symbolic reference from D to a field in a class or interface C, the symbolic reference to C given by the field reference must first be resolved ([§5.4.3.1](5.4.3.1.md)). Therefore, any exception that can be thrown as a result of failure of resolution of a class or interface reference can be thrown as a result of failure of field resolution. If the reference to C can be successfully resolved, an exception relating to the failure of resolution of the field reference itself can be thrown.

When resolving a field reference, field resolution first attempts to look up the referenced field in C and its superclasses:

1. If C declares a field with the name and descriptor specified by the field reference, field lookup succeeds. The declared field is the result of the field lookup.
2. Otherwise, field lookup is applied recursively to the direct superinterfaces of the specified class or interface C.
3. Otherwise, if C has a superclass S, field lookup is applied recursively to S.
4. Otherwise, field lookup fails.

Then:

- If field lookup fails, field resolution throws a `NoSuchFieldError`.

- Otherwise, if field lookup succeeds but the referenced field is not accessible ([§5.4.4](5.4.4.md)) to D, field resolution throws an `IllegalAccessError`.

- Otherwise, let `<`E, `L_1>` be the class or interface in which the referenced field is actually declared and let `L_2` be the defining loader of D.

  Given that the type of the referenced field is T_f, let T be T_f if T_f is not an array type, and let T be the element type ([§2.4](2.4.md)) of T_f otherwise.

  The Java Virtual Machine must impose the loading constraint that T^{L_1} = T^{L_2} ([§5.3.4](5.3.4.md)).
