A class file writes types as short strings in Utf8 entries, called descriptors. Every field, method, NameAndType entry and local variable has one. The explorer reads them as later readers do.
Field descriptors
The type of a field, a local variable, a parameter or a return value. An array type
puts one [ in front for each dimension.
| Descriptor | Java type | Slots |
|---|---|---|
B | byte | 1 |
C | char | 1 |
D | double | 2 |
F | float | 1 |
I | int | 1 |
J | long | 2 |
S | short | 1 |
Z | boolean | 1 |
LClassName; | an instance of the class, with / between packages: Ljava/lang/String; is String | 1 |
[type | one array dimension: [I is int[] | 1 |
The slots column is how many local variable slots and stack places a value of the type takes.
Method descriptors
The parameter types in brackets, then the return type, which may be V
for void:
MethodDescriptor: ( {FieldDescriptor} ) ReturnDescriptor
ReturnDescriptor: FieldDescriptor | V
| Descriptor | Method |
|---|---|
()V | void m() |
([Ljava/lang/String;)V | void main(String[] args) |
(IDLjava/lang/Thread;)Ljava/lang/Object; | Object m(int i, double d, Thread t) |
The descriptor does not include this. Because the
Code header gives
max_locals one byte, a method’s parameters and locals together fit in 255
slots.
In the explorer
The explorer turns descriptors back into Java types wherever it shows a member, and
marks a descriptor_index whose text is not a valid descriptor.