Loading mechanism of Java classes
1、 Class loading mechanism
The virtual machine loads the data describing the class from the class file into memory, verifies, converts, parses and initializes the data, and finally forms a Java type that can be directly used by the virtual machine, which is the class loading mechanism of the virtual machine.
Class loading refers to the loading of a class The binary data in the class file is read into memory, put it in the method area of the runtime data area, and then create a Java Lang. class object, used to encapsulate the data structure of the class in the method area. The final product of class loading is the class object located in the heap. The class object encapsulates the data structure of the class in the method area and provides Java programmers with an interface to access the data structure in the method area.
The class loader does not need to wait until a class is "actively used for the first time". The JVM specification allows the class loader to pre load a class when it expects it to be used. If it encounters a problem during the pre loading process Class file is missing or there is an error. The class loader must report an error when the program actively uses the class for the first time (linkageerror error). If this class has not been actively used by the program, the class loader will not report an error
2、 Class loading timing
3、 Class loading process
Next, let's explain in detail the whole process of class loading in Java virtual machine, that is, the specific actions performed in the five stages of loading, validation, preparation, parsing and initialization.
3.1 loading
reference resources:
https://www.cnblogs.com/ityouknow/p/5603287.html
https://www.cnblogs.com/javaee6/p/3714716.html
https://baijiahao.baidu.com/s?id=1658299223471945338&wfr=spider&for=pc
Zhou Zhiming, in-depth understanding of Java virtual machine: JVM advanced features and best practices