The constant pool

Every name, type, string and number a class uses is stored once in its constant pool, and everything else refers to it by index. These are its 17 kinds of entry.

The constant pool comes right after the version numbers and is usually the largest part of a class file: across JDK 25.0.5's java.base it averages 143 entries a class, the biggest has 6,004 (sun.util.resources.cldr.LocaleNames_en). Entries are numbered from 1; index 0 means "none" (a class with no superclass has super_class 0). Each starts with a one-byte tag that says what kind it is and so how long it is, which is why the pool has to be read in order from the start.

Entries build on each other. A call such as System.out.println("hi") touches a Fieldref (class System, field out), a Methodref (class PrintStream, method println), two NameAndTypes, two Classes and a String, all ending in Utf8 text. The viewer shows every reference as a link.

TagKindSinceSizeldcIn java.baseWhat it is
1Utf8Java 1.0variable603,262Most of a class file is Utf8 entries: class names, member names, descriptors, string contents, attribute names.
3IntegerJava 1.05 bytesyes10,819An int constant.
4FloatJava 1.05 bytesyes100A float constant.
5LongJava 1.09 bytesyes4,374A long constant, loaded with ldc2_w.
6DoubleJava 1.09 bytesyes1,435A double constant, loaded with ldc2_w.
7ClassJava 1.03 bytesyes84,644A class or interface, by its internal name: dots become slashes.
8StringJava 1.03 bytesyes59,564A java.lang.String literal.
9FieldrefJava 1.05 bytes35,942A reference to a field.
10MethodrefJava 1.05 bytes98,719A reference to a method of a class.
11InterfaceMethodrefJava 1.05 bytes14,940A reference to a method of an interface.
12NameAndTypeJava 1.05 bytes139,071A member's name and type without its class.
15MethodHandleJava 74 bytesyes2,634A handle to a field or method, with a kind that says how to use it.
16MethodTypeJava 73 bytesyes1,699A method descriptor as a value: loads as a java.lang.invoke.MethodType.
17DynamicJava 115 bytesyes0A constant whose value a bootstrap method computes the first time it is loaded, and which then never changes ("condy", constant dynamic).
18InvokeDynamicJava 75 bytes2,143A call site for invokedynamic: which bootstrap method links it and the call's name and type.
19ModuleJava 93 bytes67A module's name.
20PackageJava 93 bytes196A package exported or opened by a module, by its internal name (demo/api).

Tags 2, 13 and 14 are unused. Long and Double entries take two slots each, so the index after one is never valid, and constant_pool_count is one more than the highest index rather than the number of entries.

Specification: JVMS §4.4, The Constant Pool.