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

# 5.4. Linking

Linking a class or interface involves verifying and preparing that class or interface, its direct superclass, its direct superinterfaces, and its element type (if it is an array type), if necessary. Resolution of symbolic references in the class or interface is an optional part of linking.

This specification allows an implementation flexibility as to when linking activities (and, because of recursion, loading) take place, provided that all of the following properties are maintained:

- A class or interface is completely loaded before it is linked.
- A class or interface is completely verified and prepared before it is initialized.
- Errors detected during linkage are thrown at a point in the program where some action is taken by the program that might, directly or indirectly, require linkage to the class or interface involved in the error.

For example, a Java Virtual Machine implementation may choose to resolve each symbolic reference in a class or interface individually when it is used ("lazy" or "late" resolution), or to resolve them all at once when the class is being verified ("eager" or "static" resolution). This means that the resolution process may continue, in some implementations, after a class or interface has been initialized. Whichever strategy is followed, any error detected during resolution must be thrown at a point in the program that (directly or indirectly) uses a symbolic reference to the class or interface.

Because linking involves the allocation of new data structures, it may fail with an `OutOfMemoryError`.

**Sections:**

- [5.4.1. Verification](5.4.1.md)
- [5.4.2. Preparation](5.4.2.md)
- [5.4.3. Resolution](5.4.3.md)
- [5.4.4. Access Control](5.4.4.md)
- [5.4.5. Overriding](5.4.5.md)
