Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Constant Pool Entries

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?

like image 849
Clashsoft Avatar asked Mar 21 '26 21:03

Clashsoft


1 Answers

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:

  • A 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.
  • The LocalVariableTable attribute [...] may be used by debuggers to determine the value of a given local variable during the execution of a method.
  • A StackMapTable attribute is used during the process of verification by type checking
  • A MethodParameters attribute records information about the formal parameters of a method, such as their names.
like image 72
Ortomala Lokni Avatar answered Mar 23 '26 09:03

Ortomala Lokni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!