Class notes -Java basis of constant pool file

Constant pool

Immediately after the version number is a constant pool, which is a type of table data items, which means there will be more constant pool of data items constitute. It is a Class file repository, but also occupy one of the largest Class file space data items.

Constants pool number is uncertain, and therefore, is in a constant pool entry u2 data type, representing the constant pool count value, the count value is 1 instead of 0 from the beginning. Therefore, constant pool is 21, in fact, your constant is 20, and the first 0 constant is vacated, the purpose of doing so is to meet "without any reference to a constant pool project," meaning, in this case you can the index is set to 0.

The main constant pool to store the following two types of constants:

Literal: constant level Java language concepts, such as text strings, declared as a constant value final and so on.

Symbolic references: symbolic references belong to the concept of the principle aspects of the build, including the following three.

  1. the fully qualified class name and an interface.

  2. The name and descriptor fields.

  3. The name and descriptor method.

Each is a constant in the constant pool table, before jdk1.7 structure different table structure data out of 11 in jdk1.7 in order to better support dynamic languages ​​call, and an additional three. A total of 14, while 14 kinds of constant specific meaning of the type represented by the table shown below.

Constant pool of the 14 tables have a common characteristic, that is the beginning of the first table is a type u1 flag, its value is to get listed in the following table sign, on behalf of which belong to this constant current constant type .

 

And these 14 constants each type has its own structure, different project types can be seen as a constant pool of the class is different class, different class defined in a different class member variables.

Total 14 kinds of table structures constant term constant pool.

Guess you like

Origin blog.csdn.net/helianus/article/details/89329708