When running javap on a very simple HelloWorld application I have some confusion on the output around the constant pool.
Test Code
p
All your class
, interface
, field
names and string
constants go into the java constant pool.
As per VM Spec ( http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html ):
The constant_pool is a table of structures (§4.4) representing various string constants, class and interface names, field names, and other constants that are referred to within the ClassFile structure and its substructures. The format of each constant_pool table entry is indicated by its first "tag" byte. The constant_pool table is indexed from 1 to constant_pool_count-1.
So in terms of constant pool something like below can be viewed as:
const #22 = String #23; // hello world
const #23 = Asciz hello world;
The value at #22 (index 22) is of type String
and its value is null terminated c string (Asciz) hello world
is at index 23.