Module java.base
Package java.lang.classfile

# Interface ClassFileVersion

≠
public abstract sealed interface ClassFileVersion
extends java.lang.classfile.ClassElement
permits jdk.internal.classfile.impl.ClassFileVersionImpl
Comparing master and cf

All Superinterfaces:
  `ClassElement, ClassFileElement`

public sealed interface ClassFileVersion extends ClassElement
Models the classfile version information for a class. Delivered as a `ClassElement` when traversing the elements of a `ClassModel` .

Since:
  24

minor and major version numbers of a `class` file (JVMS 4.1). The `class` file version appears exactly once in each class, and is set to an unspecified default value if not explicitly provided.

The major versions of `class` file format begins at 45 for Java Platform version 1.0.2, and is continuous up to `ClassFile.latestMajorVersion()` . In general, each major version defines a new supported `class` file format, modeled by `ClassFileFormatVersion` , and supports all previous formats.

For major versions up to 55 for Java SE Platform 11, the minor version of any value is supported. For major versions 56 for Java SE Platform version 12 and above, the minor version must be `0` or 65535. The minor version `0` is always supported, and represents the format modeled by `ClassFileFormatVersion` . The minor version `65535` indicates the `class` file uses preview features of the Java SE Platform release represented by the major version. A Java Virtual Machine can only load such a `class` file if it has the same Java SE Platform version and the JVM has preview features enabled.

See Java Virtual Machine Specification:
  4.1 The `ClassFile` Structure
Since:
  24
See Also:
  - `ClassModel.majorVersion()`
  - `ClassModel.minorVersion()`
  - `ClassFileFormatVersion`

## Methods

- ≠
  public abstract int majorVersion()
  Comparing master and cf

  ### majorVersion

  int majorVersion()
  Returns the major classfile version, as an unsigned short.
  API Note:
    Constants in `ClassFile` named `Java_#_VERSION` , where # is a release number, such as `ClassFile.JAVA_21_VERSION` , describe the class major versions of the Java Platform SE.
  Returns:
    the major classfile version, as an unsigned short
- ≠
  public abstract int minorVersion()
  Comparing master and cf

  ### minorVersion

  int minorVersion()
  Returns the minor classfile version, as an unsigned short.
  Returns:
    the minor classfile version, as an unsigned short
- ≠
  public static java.lang.classfile.ClassFileVersion of(int arg0, int arg1)
  Comparing master and cf

  ### of

  static ClassFileVersion of (int majorVersion, int minorVersion)
  Returns a `ClassFileVersion` element.
  Parameters:
    `majorVersion` - the major classfile version
    `minorVersion` - the minor classfile version
  Returns:
    a `ClassFileVersion` element

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
ClassFileVersion |  |  |  |  |  |  | 3 |  | 5 | 8
majorVersion() |  |  |  |  |  |  | 3 |  | 1 | 4
minorVersion() |  |  |  |  |  |  | 4 |  | 2 | 6
of(int,int) |  |  |  |  |  |  |  |  | 2 | 2
Total |  |  |  |  |  |  | 10 |  | 10 | 20