CONSTANT_Fieldref tag 9
A reference to a field.
- Tag
9- Since
- class file 45.0 (Java 1.0)
- Size
- 5 bytes
- Loadable
- no
- Referred to by
- getfield, putfield, getstatic, putstatic
- MethodHandle entries of kinds 1 to 4
Layout
| Type | Field | What it holds |
|---|---|---|
u1 | tag | 9 |
u2 | class_index | a Class: the class to look the field up in |
u2 | name_and_type_index | a NameAndType: the field's name and type descriptor |
What it is for
A reference to a field. The class is where resolution starts, which is the type of the expression in the source, not necessarily the class that declares the field: the JVM searches superclasses and superinterfaces from there.
How common it is
JDK 25.0.5's java.base has 35,942 Fieldref constants in 5,402 of its 7,391 classes: 3.4% of all 1,059,609 constants.
A real one, byte by byte
Constant #9 of Hello.class, compiled by javac 25:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 68 | 5 bytes | #9 Fieldref | java/lang/System.out:Ljava/io/PrintStream; |
| 68 | 09 | tag | 9 (Fieldref) |
| 69 | 00 0a | class_index | #10 |
| 71 | 00 0b | name_and_type_index | #11 |
Specification: JVMS §4.4, CONSTANT_Fieldref_info (Java SE 25).