The class loading mechanism of a virtual machine is that the JVM loads the data from the. class file into memory from the description class and verifies, parses, and initializes the data, eventually creating a Java type that can be used directly by the JVM.
Load, connect (validate, prepare, parse), initialize, use, uninstall. Where parsing can be placed after initialization.
Load:
First, based on the full name of the class (Com.example.test.class), gets the binary byte stream that defines this class
Second, analyze and transfer the binary bytes into the method area (information of storage class, final, static variable)
Third, produce Java.lang.class object
Verify:
File format, class is not abstract class, is there a parent class, whether the parent class is allowed to inherit (final) and so on
Get ready:
allocating memory for class variables and setting initial values (0)
Analytical:
Convert a symbol reference to a direct reference (memory directly to the target)
Initialization
Encountering new, reflection, subclass initialization initializes the parent class, which is the active reference of the main class where main () is initialized.
Initialization is the last step in class loading, assigning values to various variables according to the values set by the programmer.
Java, JVM class loading mechanism