Java Reference
In-Depth Information
D.3.2 Names and Descriptors
Class and interface names that appear in the
ClassFile
structure are always represented
in a fully qualified form, with identifiers making up the fully qualified name separated by
forward slashes (`/')
4
. This is the so-called internal form of class or interface names. For
example, the name of class
Thread
in internal form is
java/lang/Thread
.
The JVM expects the types of fields and methods to be specified in a certain format
called descriptors.
A field descriptor is a string representing the type of a class, instance, or local variable.
It is a series of characters generated by the grammar
5
:
FieldDescriptor ::= FieldType
ComponentType ::= FieldType
FieldType ::= BaseType j ObjectType j ArrayType
BaseType ::=
B
j
C
j
D
j
F
j
I
j
J
j
S
j
Z
ObjectType ::=
L<classname>;
// class name is in internal form
ArrayType ::=
[
ComponentType
The interpretation of the base types is shown in the table below:
Basic Type Character
Type
B
byte
C
char
D
double
F
float
I
int
J
long
S
short
Z
boolean
For example, the table below indicates the field descriptors for various field declarations:
Field
Descriptor
inti; I
Objecto; Ljava/lang/Object;
double[][][]d;[[[D
Long[][]l; [[Ljava/lang/Long;
A method descriptor is a string that represents the types of the parameters that the
method takes and the type of the value that it returns. It is a series of characters generated
by the grammar:
4
This is different from the familiar syntax of fully qualified names, where the identifiers are separated
by periods (`.').
5
This is the so-called EBNF (Extended Backus Naur Form) notation for describing the syntax of lan-
guages.
Search WWH ::
Custom Search