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.
ClassFile Structure
ClassFile#parse(byte[]), ClassTransform
| Modifier and Type | Method and Description |
|---|---|
| public ConstantPool | |
| public List | |
| public AccessFlags | |
| public List | Returns: the interfaces implemented by this classReturns the interfaces implemented by this class. |
| public boolean | Returns: whether thisclass file is a module descriptorReturns whether this |
| public int | |
| public List | |
| public int | |
| public Optional | Returns: the superclass of this class, if there is oneReturns the superclass of this class, if there is one. |
| public ClassEntry | Returns: the constant pool entry describing the name of this classReturns the constant pool entry describing the name of this class. |
| constantPool | back to summary |
|---|---|
| public ConstantPool constantPool() Returns the constant pool for this class.
| |
| fields | back to summary |
|---|---|
| public List Returns the fields of this class.
| |
| flags | back to summary |
|---|---|
| public AccessFlags flags() Returns the access flags.
| |
| interfaces | back to summary |
|---|---|
| public List Returns the interfaces implemented by this class.
| |
| isModuleInfo | back to summary |
|---|---|
| public boolean isModuleInfo() Returns whether this
| |
| majorVersion | back to summary |
|---|---|
| public int majorVersion() Returns the major version of this class. It is a
| |
| methods | back to summary |
|---|---|
| public List Returns the methods of this class.
| |
| minorVersion | back to summary |
|---|---|
| public int minorVersion() Returns the minor version of this class. It is a
| |
| superclass | back to summary |
|---|---|
| public Optional Returns the superclass of this class, if there is one.
This
| |
| thisClass | back to summary |
|---|---|
| public ClassEntry thisClass() Returns the constant pool entry describing the name of this class.
| |