The life cycle of a class:
after a class has been compiled, the next step is to start using the class, and if you want to use a class, you can't do without JVM . In program execution , the JVM is completed by loading, linking, and initializing these 3 steps.
The loading of the class is done through the ClassLoader, and the loader will . Class Binary file loading of files JVM and create a description of the class in the heap area . Java.lang.Class object. Used to encapsulate data. but the same class will only be loaded by the class loader before
A link is the ability to assemble binary data into a functioning state.
links are divided into calibration, preparation, parsing this 3 Stages of
a checksum is used to verify that the binary is suitable for the current JVM (version),
Preparation is the allocation of memory space for static members. and set the default value
Parsing refers to the process of converting code in a constant pool as a direct reference, until all symbolic references can be used by the running program (establishing a complete correspondence relationship)
After completion, the type is initialized, and after initialization the object of the class can be used normally until an object is no longer in use and will be garbage collected. Free up space.
when no reference is directed to the Class object is unloaded, ending the life cycle of the class
Life cycle of Java classes _ mechanism