class index, parent class index, and interface index collectionThe above describes the class file, the magic number from the beginning, the minor version number, the major version number, the constant pool entry, the constant pool, the access flag. Then the next step is to determine the class index of the class's inheritance, the parent class index and the interface index collection three items.
Here are three things to know.
The class index (This_class) and the parent class index (SUPER_CLASS) are data of a U2 type, and the interface index collection (interfaces) is a collection of data of the U2 type, which is determined by the three data in the class file.
The class index is used to determine the fully qualified name of this class, and the parent class index is used to determine the fully qualified name of the parent class of the class. The interface index collection is used to describe which interfaces this class implements, and the implemented interfaces are arranged from left to right in the interface index collection after the implements statement.
Class index, the parent class index and the interface are sorted sequentially after the access flag, the class index and the parent index are represented by index values of two U2 types, each pointing to a class description constant of type Constant_class_info, by Conctant_class_ The index value in a constant of type info can find the fully qualified name string that is defined in a constant of type constant_class_info.
For the interface index collection, the first entry of the U2 type of data for the interface counter (Interface_count) represents the capacity of the Index table. If the class does not implement any interfaces, the counter value is 0, and the index table of the subsequent interface no longer consumes any bytes.
below we continue the previous analysis of the class file, continue to go down, analyze the above three things:
class file and Analysis:
So now we're going to take these values and we'll show you the constant pool when you analyze the constant pool with the JAVAP tool, and verify that the contents of the constant pool are correct.
Because 0x00 03 and 0x00 46 are binary corresponding to decimal 3 and 4, the class index and parent class index correspond to the third and fourth constant pools. From the third and fourth Chang respectively corresponding to the TestClass and object two classes, and then look at the source code, you know the result is correct. (Because my class name is TestClass, does not show inheritance of any class, that is, the default inherits the object parent class)
Source:
Jvm-class index, parent index and index collection