Interface ClassModel
- All Superinterfaces:
- AttributedElement,- ClassFileElement,- CompoundElement<ClassElement>,- Iterable<ClassElement>
Models a 
class file.  A class file can be viewed as a
 composition of ClassElements, 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 ClassFileStructure
- Since:
- 24
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionReturns the constant pool for this class.fields()Returns the fields of this class.flags()Returns the access flags.Returns the interfaces implemented by this class.booleanReturns whether thisclassfile is a module descriptor.intReturns the major version of this class.methods()Returns the methods of this class.intReturns the minor version of this class.Returns the superclass of this class, if there is one.Returns the constant pool entry describing the name of this class.Methods declared in interface java.lang.classfile.AttributedElementattributes, findAttribute, findAttributesMethods declared in interface java.lang.classfile.CompoundElementelementList, elementStream, forEach, iterator, toDebugStringMethods declared in interface java.lang.Iterablespliterator
- 
Method Details- 
constantPoolConstantPool constantPool()Returns the constant pool for this class.- Returns:
- the constant pool for this class
- See Also:
 
- 
flags
- 
thisClassClassEntry thisClass()Returns the constant pool entry describing the name of this class.- Returns:
- the constant pool entry describing the name of this class
 
- 
majorVersionint 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:
 
- 
minorVersionint 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
- 
methods
- 
superclassOptional<ClassEntry> superclass()Returns the superclass of this class, if there is one. Thisclassfile may have no superclass if this represents a module descriptor or theObjectclass; 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:
 
- 
interfacesList<ClassEntry> interfaces()Returns the interfaces implemented by this class.- Returns:
- the interfaces implemented by this class
- See Also:
 
- 
isModuleInfoboolean isModuleInfo()Returns whether thisclassfile is a module descriptor.- Returns:
- whether this classfile is a module descriptor
- See Also:
 
 
-