After the interfaces come the class’s fields, then its methods. Each list is a two-byte count followed by that many entries. Fields and methods have the same shape: flags, a name, a descriptor and a list of attributes.
field_info
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 2 | u2 | access_flags | The field flags |
| 2 | 2 | u2 | name_index | A Utf8 entry: the field’s name |
| 4 | 2 | u2 | descriptor_index | A Utf8 entry: a field descriptor |
| 6 | 2 | u2 | attributes_count | The number of attributes |
| 8 | varies | attribute_info[] | attributes | The field’s attributes |
The one attribute a field may carry in this format is ConstantValue, the value of a constant field.
method_info
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 2 | u2 | access_flags | The method flags |
| 2 | 2 | u2 | name_index | A Utf8 entry: the method’s name, or <init> for a constructor or <clinit> for the class initialiser |
| 4 | 2 | u2 | descriptor_index | A Utf8 entry: a method descriptor |
| 6 | 2 | u2 | attributes_count | The number of attributes |
| 8 | varies | attribute_info[] | attributes | The method’s attributes |
A method that is neither abstract nor native has a Code attribute, with this format’s 4-byte header. A method may also carry an Exceptions attribute, the checked exceptions it declares.
The explorer names each field and method after itself and shows it as a Java
declaration built from its flags and descriptor, such as
public static void main(java.lang.String[]).
An example method
The one method of the example file, at offset 0xCF:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 0xCF | 00 01 | access_flags | ACC_PUBLIC |
| 0xD1 | 00 06 | name_index | #6, <init> |
| 0xD3 | 00 05 | descriptor_index | #5, ()V |
| 0xD5 | 00 01 | attributes_count | 1 |
| 0xD7 | 00 07 00 00 00 0D … | attributes | a Code attribute of 13 bytes |