First, load
1. Obtain a binary byte stream that defines this class by using the fully qualified name of a class.
2. Convert the static storage structure represented by this byte stream into the run-time data structure of the method area.
3. Generate a Java.lang.Class object representing this class in memory as the access entry for various data of this class in the method area.
Second, verification
1. File Format Verification
Verifies that the byte stream conforms to the specification of the class file format and can be processed by the current version of the virtual machine.
2. Meta-data validation
The information of byte code seconds is analyzed in semantics to ensure that the information described is in accordance with the requirements of Java language Specification.
3. Byte code Verification
Through data flow and control flow analysis, it is reasonable to determine that the program semantics are legal and logical . After verifying the data types in the metadata information in the second round, this phase verifies the method of the class to ensure that the method of the checked class does not make an event that endangers the security of the virtual machine at run time.
4. Symbol Reference Validation
A matching check of information outside the class itself (a variety of symbol references in a constant pool) is intended to ensure that the parsing action is performed properly and that an exception is thrown if it cannot be verified by a symbolic reference.
Third, prepare
A stage that formally allocates memory for class variables and sets the initial value of class variables, the memory used by these variables will be allocated in the method area.
The memory allocation at this time includes only class variables (static modified variables), not instance variables, which will be assigned to the Java heap with the object when the object is instantiated, and initialization of the class variable instead of assigning the class variable to the final initialization value, rather than assigning the value to a 0 value of the data type.
For example, public static int value=123; In the preparation phase, the value is simply assigned to the value 0 of int, which is 0, not 123 (the program is compiled before it is assigned a value of 123)
Iv. Analysis
The parsing phase is the process by which a virtual machine replaces a symbolic reference within a constant pool with a direct reference.
Symbol references can be any form of literal, depending on the virtual machine may be different, but they can be targeted to the target, in the class file is defined.
A direct reference is a pointer, relative offset, or a handle that can be directed directly to the target.
V. Initialization
At the initialization stage, the Java program code that actually starts executing the definition is started. At this stage, the programmer initializes the class variables and other resources through a subjective plan developed by the program.
The true assignment is performed at this stage , which is the public static int value=123 of the preparation phase; At this stage value will now be assigned a value of 123