---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 11 Edition"
java_version: 11
chapter: "Chapter 5. Loading, Linking, and Initializing"
section: "5.3.5"
heading: "5.3.5. Deriving a Class from a class File Representation"
parent: "5.3. Creation and Loading"
source: https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-5.html#jvms-5.3.5
id: "5.3.5"
url: https://jvm.obfuscated.software/jvms/se11/5.3.5.html
raw: https://jvm.obfuscated.software/jvms/se11/5.3.5.md
---

# 5.3.5. Deriving a Class from a `class` File Representation

The following steps are used to derive a `Class` object for the nonarray class or interface C denoted by `N` using loader `L` from a purported representation in `class` file format.

1. First, the Java Virtual Machine determines whether it has already recorded that `L` is an initiating loader of a class or interface denoted by `N`. If so, this creation attempt is invalid and loading throws a `LinkageError`.

2. Otherwise, the Java Virtual Machine attempts to parse the purported representation. However, the purported representation may not in fact be a valid representation of C.

   This phase of loading must detect the following errors:

   - If the purported representation is not a `ClassFile` structure ([§4.1](4.1.md), [§4.8](4.8.md)), loading throws an instance of `ClassFormatError`.

   - Otherwise, if the purported representation is not of a supported major or minor version ([§4.1](4.1.md)), loading throws an instance of `UnsupportedClassVersionError`.

     `UnsupportedClassVersionError`, a subclass of `ClassFormatError`, was introduced to enable easy identification of a `ClassFormatError` caused by an attempt to load a class whose representation uses an unsupported version of the `class` file format. In JDK release 1.1 and earlier, an instance of `NoClassDefFoundError` or `ClassFormatError` was thrown in case of an unsupported version, depending on whether the class was being loaded by the system class loader or a user-defined class loader.

   - Otherwise, if the purported representation does not actually represent a class named `N`, loading throws an instance of `NoClassDefFoundError` or an instance of one of its subclasses.

     This occurs when the purported representation has either a `this_class` item which specifies a name other than `N`, or an `access_flags` item which has the `ACC_MODULE` flag set.

3. If C has a direct superclass, the symbolic reference from C to its direct superclass is resolved using the algorithm of [§5.4.3.1](5.4.3.1.md). Note that if C is an interface it must have `Object` as its direct superclass, which must already have been loaded. Only `Object` has no direct superclass.

   Any exceptions that can be thrown due to class or interface resolution can be thrown as a result of this phase of loading. In addition, this phase of loading must detect the following errors:

   - If the class or interface named as the direct superclass of C is in fact an interface, loading throws an `IncompatibleClassChangeError`.
   - Otherwise, if any of the superclasses of C is C itself, loading throws a `ClassCircularityError`.

4. If C has any direct superinterfaces, the symbolic references from C to its direct superinterfaces are resolved using the algorithm of [§5.4.3.1](5.4.3.1.md).

   Any exceptions that can be thrown due to class or interface resolution can be thrown as a result of this phase of loading. In addition, this phase of loading must detect the following errors:

   - If any of the classes or interfaces named as direct superinterfaces of C is not in fact an interface, loading throws an `IncompatibleClassChangeError`.
   - Otherwise, if any of the superinterfaces of C is C itself, loading throws a `ClassCircularityError`.

5. The Java Virtual Machine marks C as having `L` as its defining class loader and records that `L` is an initiating loader of C ([§5.3.4](5.3.4.md)).
