Home > Java > JavaBase > What are the stages of jvm class loading process?

What are the stages of jvm class loading process?

青灯夜游
Release: 2023-01-13 00:40:03
Original
13768 people have browsed it

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.

What are the stages of jvm class loading process?

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.

What are the stages of jvm class loading process?

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 method and call it.

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:

What are the stages of jvm class loading process?

##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?ing /lib/rt.jar.

2. Extension ClassLoader is responsible for What are the stages of jvm class loading process?ing the packages under /lib/ext.

3. Application ClassLoader is responsible for What are the stages of jvm class loading process?ing the JAVA class library under the CLASSPATH path.

4. User ClassLoader User-defined class What are the stages of jvm class loading process?er.

The parent What are the stages of jvm class loading process? model uses this method to What are the stages of jvm class loading process? classes: when the class What are the stages of jvm class loading process?er receives a request to What are the stages of jvm class loading process? a class, it first delegates the parent class to What are the stages of jvm class loading process? the class. All class What are the stages of jvm class loading process?ers use this method, so all class What are the stages of jvm class loading process?ing requests They will all reach the top-level parent class. If the parent class cannot be What are the stages of jvm class loading process?ed, the class What are the stages of jvm class loading process?er will be used to What are the stages of jvm class loading process? it. In this way, there is a hierarchical relationship between class What are the stages of jvm class loading process?ers, which can ensure that Java's basic classes are What are the stages of jvm class loading process?ed by the same class What are the stages of jvm class loading process?er, which plays a vital role in the stability of the Java system.

Recommended related video tutorials:

Java video tutorial

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template