---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 18 Edition"
java_version: 18
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/se18/html/jvms-5.html#jvms-5.4.3.2
id: "5.4.3.2"
url: https://jvm.obfuscated.software/jvms/se18/5.4.3.2.html
raw: https://jvm.obfuscated.software/jvms/se18/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, the result of field resolution is determined:

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

- Otherwise, field lookup succeeded. Access control is applied for the access from D to the field which is the result of field lookup ([§5.4.4](5.4.4.md)). Then:

  - If access control failed, field resolution fails for the same reason.

  - Otherwise, access control succeeded. Loading constraints are imposed, as follows.

    Let `<`E, `L_1>` be the class or interface in which the referenced field is actually declared. Let `L_2` be the defining loader of D. Given that the type of the referenced field is T_f: if T_f is not an array type, let T be T_f; otherwise, let T be the element type of T_f.

    The Java Virtual Machine imposes the loading constraint that T^{L_1} = T^{L_2}.

    If imposing this constraint results in any loading constraints being violated ([§5.3.4](5.3.4.md)), then field resolution fails. Otherwise, field resolution succeeds.
