JVM basics essential articles

JVM basics essential articles

1. Known from the official documents in the class: JDK: contains JRE, JRE: contains JVM JDK>JRE>JVM

2. The role of the class loading mechanism: convert the class file into runtime data
that can be recognized by the JVM . The process of the class loading mechanism:
01. Load: Find the class file, find the full path of the file on the disk, and convert it to The form of the stream in Java
--------------------------------------
How to load? Make a class loading thing, class loader: Classloader, different class loader areas load classes in different directories, there will be problems,
interview inspection point: java.lang.String class, loaded by Bootstrap ClassLoader class, in different directories Loading different classes, if there are two classes loaded with the same full path, there will be problems when using the classes.
Solution: Let the class loading process be organized and have certain rules. Before the class is loaded by the classloader() method of the class loader, go to the parent class to find it. If it has already been loaded in the parent class, the subclass does not need to be loaded again.
If the parent class cannot be loaded, the subclass (load class) will load the class. If the two classes are not loaded into the class, then the class does not exist —> throw an exception (notFoundClassloaderException)
and search for the ClassLoader class in Java In the loadClass() method, this.parent.loadClass, if it is not found, an exception will be thrown. Name: Parental delegation mechanism—
>Break the parental delegation mechanism: rewrite loadClass

Guess you like

Origin blog.csdn.net/qq_43070471/article/details/104535362