The life cycle of a class isLoading、ConnectionAndInitializeStart, to the end of the class being unloaded.
A Java program can use a class only if it is in its life cycle, such as calling static properties and methods of a class, or creating a real column of a class
Brief introduction
1: Load
The load time of a class refers to reading the binary in the class's. class file into memory, storing it in the method area of the runtime data area, and then creating a Java.long.Class object in the heap to encapsulate the data structure of the class within the method area. It also provides a Java program with access to the data structure interface of the class within the method area.
The ClassLoader of a class does not require a class "first active use" when loading it, and the Java Virtual Machine specification allows the ClassLoader to anticipate that a class will be used, preload it
2: Connect
2.1: Verify
2.2: Prepare
2.3: Parsing
3: Initialize the static variable to the class to give the correct initial value
Unlike loading, Java virtual machines are initialized only when a program uses a class or interface for the first time.
3.1: Create a real column of the class (new, Reflection, clone, serialization)
3.2: Calling a static method of a class
3.3: Access static variables of the class (you can see that the static variable is initialized when the actual column of the class does not exist)
3.4: Initializes a subclass of a class. That is, the initialization of a subclass initializes the parent class (calling the constructor of the parent class), which is why the object class has a default parameterless construction method.
3.5: Subclass of the startup class identified by the Java Virtual machine
Supplemental: Class-loaded Father delegation mechanism
The life cycle of the Java class and the initialization time of the class