Module java.base
Package java.lang.classfile

# Interface ClassModel

≠
public abstract sealed interface ClassModel
extends java.lang.classfile.AttributedElement, java.lang.classfile.CompoundElement<java.lang.classfile.ClassElement>
permits jdk.internal.classfile.impl.ClassImpl
Comparing master and cf

All Superinterfaces:
  `AttributedElement, ClassFileElement, CompoundElement<ClassElement>, Iterable<ClassElement>`

public sealed interface ClassModel extends CompoundElement<ClassElement>, AttributedElement
Models a classfile. The contents of the classfile can be traversed via a streaming view, or via random access (e.g., `flags()` ), or by freely mixing the two.

Since:
  24

`class` file. A `class` file can be viewed as a composition of `ClassElement` s, or by random access via accessor methods if only specific parts of the `class` file is needed.

Use `ClassFile.parse(byte[])` , which parses the binary data of a `class` file into a model, to obtain a `ClassModel` .

To construct a `class` file, use `ClassFile.build(ClassDesc, Consumer)` . `ClassFile.transformClass(ClassModel, ClassTransform)` allows creating a new class by selectively processing the original class elements and directing the results to a class builder.

A class holds attributes, most of which are accessible as member elements. `BootstrapMethodsAttribute` can only be accessed via explicit attribute reading, as it is modeled as part of the constant pool.

See Java Virtual Machine Specification:
  4.1 The `ClassFile` Structure
Since:
  24
See Also:
  - `ClassFile.parse(byte[])`
  - `ClassTransform`

## Methods

- ≠
  public abstract java.lang.classfile.constantpool.ConstantPool constantPool()
  Comparing master and cf

  ### constantPool

  ConstantPool constantPool()
  Returns the constant pool for this class.
  Returns:
    the constant pool for this class
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list-long.
    - `ConstantPoolBuilder.of(ClassModel)`
- =
  public abstract java.util.List<java.lang.classfile.FieldModel> fields()
- ≠
  public abstract java.lang.classfile.AccessFlags flags()
  Comparing master and cf

  ### flags

  AccessFlags flags()
  Returns the access flags.
  Returns:
    the access flags
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `AccessFlag.Location.CLASS`
- ≠
  public abstract java.util.List<java.lang.classfile.constantpool.ClassEntry> interfaces()
  Comparing master and cf

  ### interfaces

  List<ClassEntry> interfaces()
  Returns the interfaces implemented by this class.
  Returns:
    the interfaces implemented by this class
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `Interfaces`
- ≠
  public abstract boolean isModuleInfo()
  Comparing master and cf

  ### isModuleInfo

  boolean isModuleInfo()
  Returns whether this `Moved to a computer code block.class` Moved to a computer code block. file is a module descriptor.
  Returns:
    whether this `Moved to a computer code block.class` Moved to a computer code block. file is a module descriptor
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list-long.
    - `ClassFile.buildModule(ModuleAttribute, Consumer)`
- ≠
  public abstract int majorVersion()
  Comparing master and cf

  ### majorVersion

  int majorVersion()
  Returns the major classfile version of this class.
  Returns:
    the major classfile version of this class
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `ClassFileVersion`
- =
  public abstract java.util.List<java.lang.classfile.MethodModel> methods()
- ≠
  public abstract int minorVersion()
  Comparing master and cf

  ### minorVersion

  int minorVersion()
  Returns the minor classfile version of this class.
  Returns:
    the minor classfile version of this class
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `ClassFileVersion`
- ≠
  public abstract java.util.Optional<java.lang.classfile.constantpool.ClassEntry> superclass()
  Comparing master and cf

  ### superclass

  Optional<ClassEntry> superclass()
  Returns the superclass of this class, if there is one. This `class` file may have no superclass if this represents a module descriptor or the `Object` class; otherwise, it must have a superclass. If this is an interface, the superclass must be `Object` .
  Returns:
    the superclass of this class, if there is one
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `Superclass`
- =
  public abstract java.lang.classfile.constantpool.ClassEntry thisClass()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
ClassModel |  |  |  |  |  |  | 3 |  | 4 | 7
constantPool() |  |  |  |  |  |  | 5 |  |  | 5
flags() |  |  |  |  |  |  | 5 |  |  | 5
interfaces() |  |  |  |  |  |  | 5 |  |  | 5
isModuleInfo() |  |  |  |  |  |  | 5 | 4 |  | 9
majorVersion() |  |  |  |  |  |  | 7 |  | 2 | 9
minorVersion() |  |  |  |  |  |  | 7 |  | 2 | 9
superclass() |  |  |  |  |  |  | 10 |  |  | 10
Total |  |  |  |  |  |  | 47 | 4 | 8 | 59