"In-depth understanding of the Java virtual machine" reading notes Chapter 6 class file structure

Click to view "In-Depth Understanding of the Java Virtual Machine" Reading and Combing Collection

Constant pool

There are two main types of constants stored in the constant pool: literals and symbolic references.
The literal quantity is closer to the concept of constants at the java language level, such as text strings, constant values ​​declared as final, and so on. Symbolic references belong to the concept of compilation principles, which mainly include the following types of constants:
1. The modules are everywhere or open packages
2. The fully qualified names of classes and interfaces
3. The names and descriptors of the fields
4. The names and descriptions of the methods Fu
the method was bar-type handle and
6. the dynamic constants and the dynamic call site
java code at compile time process is not connected, but are connected in a virtual machine dynamically loaded class file, the class file that is not stored Each method, the layout information of the field in the memory. Their symbolic references are converted by the virtual machine at runtime to get the real memory entry address. When the virtual machine loads a class, it will obtain the corresponding symbol reference from the constant pool, and then resolve it when the class is created or at runtime, and translate it into a specific memory address

Access sign

After the end of the constant pool, the next two bytes represent the access flag. This flag is used to identify some class or interface-level access information, including: whether this Class is a class or an interface; whether it is public, whether it is abstract, if it is a class If it is declared as final, etc.

Class index, parent class index, interface index collection

After the access mark, there is a collection of class index, parent class index, and interface index. Both the class index and the husband class index are data of type u2. And the interface index collection is a collection of u2 type data. The Class file uses these three data to determine the inheritance relationship of the type. The class index is used to determine the fully qualified class name of this class, and the parent class index determines the fully qualified class name of the parent class. The interface index collection is used to describe which interfaces this class implements.

Field table collection

The field table records the modifier (public abstract transient, etc.) of each field, the name (username) and descriptor (basic data type array) index (pointing to the constant pool) and an attribute table. The attribute table is used to record some additional information. For example, a final int a = 123 in life. Then there will be an index pointing to the literal 123,

Method table collection

The same as the content of the field table collection, the release is composed of modifiers (sychnorize native public, etc.), indexes of names (toString) and descriptors (parameter list + return value type), and an attribute table. The code of the method is stored in the attribute table. In an attribute named code.

Attribute table collection

Guess you like

Origin blog.csdn.net/qq_30033509/article/details/114991533