First, the kind of life cycle
Wherein the connection phase position collectively large box, after the initialization process can be resolved.
Second, the class loading process
1, Load
The first step in the process of class loading, mainly to complete the following three things:
- Such acquired defined by the full class name of a binary byte stream
- Converting the byte stream static storage structure represented by the run-time data structure area method
- Generating in memory a representative of the class Class object, such as a method of access to data entry area
One non-loading phase array class (class loading phase acquisition operation binary byte stream) is controllable strongest stage, to complete this step we can also customize the class loader to control the manner of obtaining the byte stream (Overrides a class loader loadClass()
methods). Array type is not created by the class loader, which created directly by the Java Virtual Machine.
After the loading stage is completed, the JVM according to a binary stream of bytes to store the desired format in the method area.
Loading phase and the connection phase for the cross.
2, verification
This phase will determine whether jvm able to withstand malicious attacks from the execution performance in terms of workload subsystem verification phase of the load jvm class has accounted for part of it.
3, the preparation phase
Formally allocate memory for class variables and class variables set the initial value of the stage.
(1) comprises a memory allocation class variables (static).
(2) the initial value of class type is usually the default value of zero.
4, parsing
Jvm the symbolic constant pool is replaced by a direct reference to a reference (class method pointer field in memory, the offset) process.
Primarily for the class or interface, fields, methods class, interface method, type method, and calls the method handle class qualifiers 7 symbolic references.
5, initialization
This is the last class loading step, this is the java program code (bytecode) defined in the real implementation class execution class constructor <clinit> method procedure.
<Clinit> copy operation is automatically compiled collection of all the variables and static class statement block merger of statements.