Interface ClassModel

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

public sealed interfaceClassModelextendsCompoundElement<ClassElement>,AttributedElement
Models aclass file. Aclass file can be viewed as acomposition ofClassElements, or by random access via accessor methods if only specific parts of the class file is needed.

UseClassFile.parse(byte[]), which parses the binary data of a class file into a model, to obtain aClassModel.

To construct aclass file, useClassFile.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 viaexplicit attribute reading, as it is modeled as part of theconstant pool.

SeeJava Virtual Machine Specification:
4.1 TheClassFile Structure
Since:
24
See Also:
  • Method Details

    • constantPool

      ConstantPool constantPool()
      Returns the constant pool for this class.
      Returns:
      the constant pool for this class
      See Also:
    • flags

      AccessFlags flags()
      Returns the access flags.
      Returns:
      the access flags
      See Also:
    • thisClass

      ClassEntry thisClass()
      Returns the constant pool entry describing the name of this class.
      Returns:
      the constant pool entry describing the name of this class
    • majorVersion

      int majorVersion()
      Returns the major version of this class. It is in the range of unsigned short,[0, 65535].
      Returns:
      the major version of this class
      See Also:
    • minorVersion

      int minorVersion()
      Returns the minor version of this class. It is in the range of unsigned short,[0, 65535].
      Returns:
      the minor version of this class
      See Also:
    • fields

      List<FieldModel> fields()
      Returns the fields of this class.
      Returns:
      the fields of this class
    • methods

      List<MethodModel> methods()
      Returns the methods of this class.
      Returns:
      the methods of this class
    • superclass

      Optional<ClassEntry> superclass()
      Returns the superclass of this class, if there is one. Thisclass file may have no superclass if this represents amodule descriptor or theObject class; otherwise, it must have a superclass. If this is an interface, the superclass must beObject.
      Returns:
      the superclass of this class, if there is one
      See Also:
    • interfaces

      List<ClassEntry> interfaces()
      Returns the interfaces implemented by this class.
      Returns:
      the interfaces implemented by this class
      See Also:
    • isModuleInfo

      boolean isModuleInfo()
      Returns whether thisclass file is a module descriptor.
      Returns:
      whether thisclass file is a module descriptor
      See Also: