Top Description Methods
java.lang.classfile

public sealed Interface ClassModel

extends CompoundElement<ClassElement>, AttributedElement
Known Direct Implementers
jdk.internal.classfile.impl.ClassImpl
Annotations
@PreviewFeature
feature:CLASSFILE_API
Imports
java.util.List, .Optional, java.util.function.Consumer, java.lang.classfile.constantpool.ClassEntry, .ConstantPool, jdk.internal.classfile.impl.ClassImpl, jdk.internal.classfile.impl.verifier.VerifierImpl, jdk.internal.javac.PreviewFeature

Preview

Second Preview of ClassFile API (JEP 466).

Programs can only use ClassModel when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

Models a classfile. The contents of the classfile can be traversed via a streaming view (e.g., elements()), or via random access (e.g., flags()), or by freely mixing the two.
Since
22

Method Summary

Modifier and TypeMethod and Description
public ConstantPool

Returns:

the constant pool for this class
constantPool
()

Returns the constant pool for this class.

public List<FieldModel>

Returns:

the fields of this class
fields
()

Returns the fields of this class.

public AccessFlags

Returns:

the access flags
flags
()

Returns the access flags.

public List<ClassEntry>

Returns:

the interfaces implemented by this class
interfaces
()

Returns the interfaces implemented by this class.

public boolean

Returns:

whether this class is a module descriptor
isModuleInfo
()

Returns whether this class is a module descriptor.

public int

Returns:

the major classfile version
majorVersion
()

Returns the major classfile version.

public List<MethodModel>

Returns:

the methods of this class
methods
()

Returns the methods of this class.

public int

Returns:

the minor classfile version
minorVersion
()

Returns the minor classfile version.

public Optional<ClassEntry>

Returns:

the superclass of this class, if there is one
superclass
()

Returns the superclass of this class, if there is one.

public ClassEntry

Returns:

the constant pool entry describing the name of this class
thisClass
()

Returns the constant pool entry describing the name of this class.

Inherited from java.lang.classfile.AttributedElement:
attributesfindAttributefindAttributes
Inherited from java.lang.classfile.CompoundElement:
elementListelementselementStreamforEachElementiterator

Method Detail

constantPoolback to summary
public ConstantPool constantPool()

Returns the constant pool for this class.

Returns:ConstantPool

the constant pool for this class

fieldsback to summary
public List<FieldModel> fields()

Returns the fields of this class.

Returns:List<FieldModel>

the fields of this class

flagsback to summary
public AccessFlags flags()

Returns the access flags.

Returns:AccessFlags

the access flags

interfacesback to summary
public List<ClassEntry> interfaces()

Returns the interfaces implemented by this class.

Returns:List<ClassEntry>

the interfaces implemented by this class

isModuleInfoback to summary
public boolean isModuleInfo()

Returns whether this class is a module descriptor.

Returns:boolean

whether this class is a module descriptor

majorVersionback to summary
public int majorVersion()

Returns the major classfile version.

Returns:int

the major classfile version

methodsback to summary
public List<MethodModel> methods()

Returns the methods of this class.

Returns:List<MethodModel>

the methods of this class

minorVersionback to summary
public int minorVersion()

Returns the minor classfile version.

Returns:int

the minor classfile version

superclassback to summary
public Optional<ClassEntry> superclass()

Returns the superclass of this class, if there is one.

Returns:Optional<ClassEntry>

the superclass of this class, if there is one

thisClassback to summary
public ClassEntry thisClass()

Returns the constant pool entry describing the name of this class.

Returns:ClassEntry

the constant pool entry describing the name of this class