Class What are the stages of jvm class loading process?ing process: 1. Loading stage; 2. Verification stage; 3. Preparation stage, mainly allocating memory and initializing class variables in the method area; 4. Parsing stage; 5. Initialization stage. The compiler will merge the static assignment variables and static areas declared in the class file to generate the cinit method and call it; 6. Use phase; 7. Uninstall phase.
The operating environment of this tutorial: windows7 system, java8 version, DELL G3 computer.
Understanding the JVM class What are the stages of jvm class loading process?ing process, we mainly need to answer two questions:
1. When is the class What are the stages of jvm class loading process?ed?
2. How the class is What are the stages of jvm class loading process?ed.
1. Conditions for triggering class What are the stages of jvm class loading process?ing:
The class What are the stages of jvm class loading process?ing process is mainly divided into seven Stages: What are the stages of jvm class loading process?ing, verification, preparation, parsing, initialization, use, and unWhat are the stages of jvm class loading process?ing; the order of the five processes of What are the stages of jvm class loading process?ing, verification, preparation, initialization, and unWhat are the stages of jvm class loading process?ing is determined. JVM must strictly follow this order. JVM does not specify the timing of class What are the stages of jvm class loading process?ing. However, it is strictly stipulated that the class must be initialized immediately under five circumstances, and What are the stages of jvm class loading process?ing must be done before this.
1. When encountering the four instructions new, getstatic, putstatic, and invokestatic, if the class has not been initialized, the class will be initialized first.
2. When using the method of the java.lang.reflect package to make a reflection call to a class, if the class has not been initialized, its initialization will be triggered.
3. When initializing a class, if the parent class of the class has not been initialized, the initialization of its parent class is first triggered.
4. To run the JVM, you must specify a main class containing the main method. The virtual machine will initialize this class first.
5. When using the dynamic language support of Jdk1.7, if the final parsing result of a java.lang.invoke.MethodHandle instance is the method handle of REF_getstatic, REF_putstatic, REF_inokestatic, and the class corresponding to this method handle This class initialization is triggered when there is no initialization.
2. Class What are the stages of jvm class loading process?ing process
The class What are the stages of jvm class loading process?ing process is mainly divided into seven stages: What are the stages of jvm class loading process?ing, verification, preparation, parsing, initialization, and use ,uninstall.
1. Loading:
1) Load the binary byte stream corresponding to a class through its fully qualified name. Mainly implemented through class What are the stages of jvm class loading process?ers.
2) Convert the static storage structure represented by the byte stream into the runtime data structure of the method area.
3), generate a java.lang.Class object representing this class in the memory, which serves as the entrance for each class in the method area to access this class. (Hotspot generates this class in the method area).
2. Verification:
1), File format verification: Verify whether the magic version number constant of the class file is within the range supported by the current virtual machine.
2), Metadata verification: Verify whether the semantic information of the class meets the requirements of the Java language specification.
3), bytecode verification: Verify that the program semantics are legal and compliant. Mainly through the stackmapframe structure.
4), Symbol reference verification: The virtual machine converts the symbol reference into a direct reference, and verifies whether the class represented by the fully qualified name of the symbol reference can be found, whether the corresponding domain and method can be found, and whether the access permission is legal. .
3. Preparation:
The preparation stage mainly allocates and initializes memory for class variables (modified by static modifier) in the method area.
Data type | Zero value | Data type | Zero value |
---|---|---|---|
int | 0 | boolean | false |
long | 0L | float | 0.0f |
short | 0 | double | 0.0d |
char | '\u0000' | reference | null |
byte | 0 |
4. Parsing:
1), Class or interface parsing: Convert the qualified reference into a direct reference to the class, and check the access permissions.
2), Field parsing: Convert the symbolic reference of the field into the class information to which the field belongs or a direct reference to the field of its parent class, and check the access permissions.
3), Class method parsing: Convert the symbolic reference of the class method into the class information to which the class method belongs or a direct reference to the field of its parent class, and check the access permissions.
4), Interface method parsing: Convert the symbolic reference of the interface method into the interface information to which the interface method belongs or a direct reference to the field of its parent class, and check the access permissions.
5. Initialization:
In the initialization phase, the compiler will merge the static assignment variables and static areas declared in the class file to generate the
Class What are the stages of jvm class loading process?er: The class What are the stages of jvm class loading process?er is the implementation of "What are the stages of jvm class loading process?ing the binary byte stream of a class through its fully qualified name". For any class, it is composed of the class What are the stages of jvm class loading process?er and the class itself. jointly determine uniqueness within the virtual machine.
Parental What are the stages of jvm class loading process? model:
##1. Bootstrap ClassLoader starts the class What are the stages of jvm class loading process?er and is responsible for What are the stages of jvm class loading process?ing2. Extension ClassLoader is responsible for What are the stages of jvm class loading process?ing the packages under
The above is the detailed content of What are the stages of jvm class loading process?. For more information, please follow other related articles on the PHP Chinese website!