Looking at the output of running javap
on some classes, I have come across the following oddity:
The Constant Pool of some classes contains entries such as
#33 = Utf8 Code
#34 = Utf8 LocalVariableTable
#35 = Utf8 StackMapTable
#36 = Utf8 MethodParameters
Why do these constants appear in the constant pool?
The following constants
#33 = Utf8 Code
#34 = Utf8 LocalVariableTable
#35 = Utf8 StackMapTable
#36 = Utf8 MethodParameters
are name of attributes.
For all attributes, the attribute_name_index must be a valid unsigned 16-bit index into the constant pool of the class. The constant_pool entry at attribute_name_index must be a CONSTANT_Utf8_info structure (§4.4.7) representing the name of the attribute.
The attributes you mention have the following functions:
Code
attribute contains the Java Virtual Machine instructions and auxiliary information for a method, including an instance initialization method or a class or interface initialization method.LocalVariableTable
attribute [...] may be used by debuggers to determine the value of a given local variable during the execution of a method.StackMapTable
attribute is used during the process of verification by type checkingMethodParameters
attribute records information about the formal parameters of a method, such as their names.