The class loading process includes: parsing---------validation---- Start in this order (not completed, may cross)
The initialization process is the execution of the class constructor <clinit> (composed of static variables, static{} block Order)
Triggers the initialization condition:
1) New, getstatic, Putstatic, incokestatic 4 bytecode, common for new instantiation, read set static field (in addition to the final modified compilation constants), call static method
2) When initializing a class, if the parent class is not initialized, the parent class is first triggered.
3) When the class is reflected
4) When the virtual machine starts, the class with main is initialized first
Instance initialization <init> (non-static variable, non-static initialization block, constructor) is not performed until the class has finished loading
Load:
Complete the following three things:
1) Get the binary byte class that defines this class by using the fully qualified name of a class
2) Speak of the experience represented by this byte stream the storage structure is transformed into the runtime data mechanism of the method area
3) In the Java heap, generate a class object that represents it as the access entry for the data in the method area
Verify:
Ensure that the information contained in the byte stream of the class file conforms to the virtual machine requirements and will not be safe for the Weihai virtual machine itself
1) file Format verification
2) meta-data validation
3) Byte code verification
4) symbol Reference validation
Get ready:
Allocates memory for class variables and sets class variable initial values, which are allocated within the method area
Static: Initial value 0,null
Static final: Based on the Constantvalue property
Analytical:
A symbolic reference in a constant pool is replaced by a direct reference to a class or interface, a field, a class method, an interface method, corresponding to the Constant_class_info, Constant_fieldref_info, constant_methodref_ of a constant pool, respectively. info, Constant_interfacemethodref_info
1) class or interface parsing: for example, Class D resolves C (symbolic Reference N) Virtual Opportunity Bar represents the fully qualified name of N to the class loader D to load C, during the loading process, may trigger other loading actions, such as C's parent class and implemented interface
2) Field parsing
3) class method parsing
4) Interface Method parsing
Initialization
Execute class constructor <clinit> () method
Java Virtual machine class loading small memory