The constant pool is part of the .class file (and its representation in memory), which contains the constants necessary to run the code for this class.
These constants include literals specified by the programmer and symbolic links generated by the compiler. Symbolic links are basically the names of the classes, methods, and fields that the code refers to. These links are used by the JVM to associate your code with other classes on which it depends.
For example, the following code
System.out.println("Hello, world!");
outputs the following bytecode ( javap output)
0: getstatic
#n Here are links to the persistent pool. #2 is a symbolic link to the System.out field, #3 is the string Hello, world! , and #4 is a symbolic link to the PrintStream.println(String) method.
As you can see, symbolic links are not just names - for example, a symbolic link to a method also contains information about its parameters ( Ljava/lang/String; ) and the return type ( V means void ).
You can check the persistent pool of a class by running javap -verbose for that class.
axtavt Apr 18 2018-12-18T00: 00Z
source share