Java ClassLoader is used to dynamically load class, ClassLoader to a class will only be loaded once, the JVM uses a total of 4 kinds of ClassLoader:
Starts the class loader, the standard extension class loader, the Classpath loader, and the network class loader.
The priority levels of these 4 classloader are high to low, using so-called "parental delegation models". To be exact, If a network class loader is requested to mount a Java.lang.Integer, it will first send the request to the class path loader on the previous level, and if it is loaded, the network class loader will not mount the Java.lang.Integer, and it will load JA if the class path loader on the previous level is not loaded. Va.lang.Integer.
Similarly, when a classpath loader receives a request (whether directly requesting mount or the next level of ClassLoader upload), it also sends the request to the standard extension class loader at the top level, uploading it one layer at a level, so that the boot class loader has the highest priority. If it finds the java.lang.Integer in its own way, the following classloader can no longer load java.lang.Integer, even though you wrote a java.lang.Integer yourself, trying to replace the core library Java.lang.Intege R is not possible, because this class of writing itself cannot be loaded at all by the lower ClassLoader.
Say the package permissions. The Java language specifies that the class in the same package, if there is no modifier, defaults to the package permission, which is accessible by the class within the bundle. But that's not accurate enough. To be exact, only the class loaded by the same ClassLoader has the above package permissions. For example, the Startup class loader loaded the java.lang.String, and the Classpath loader loaded our own java.lang.Test, and they could not access each other's methods with the package permissions. This prevents the malicious code from accessing the package permission method of the core class.
A brief introduction to Java's class loading mechanism