Loading of classes
When the program actively uses a class is, if the class has not been loaded into memory, the system will be loaded, linked, initialized three steps to initialize the class, if there is no accident, the JVM will complete the three steps, so it is sometimes referred to the three steps of the class loading and initialization of the class.
A class is loaded by reading the class file into memory and creating a Java.lang.Class object for it, which means that when any class is used in the program, a Java.lang.Class object is created for it
Class loading is done by the ClassLoader of the class, which is typically providedby the JVM , which is the basis for the program to run, and the loader that theJVM provides is called the system loader, and in addition, developers can inherit Class Loader base class to create your own loader
With different loaders, binary data can be loaded from different sources
- Loading the class file locally
- Load a class file from the JAR Package
- Load class files over the network
- dynamically compile and load a Java source file
The class loader does not have to wait until the class is first used to load, and the Java Virtual machine specification allows some classes to be preloaded
And look back on the 15th day of Java