Why JVM class loader loading mechanism to adopt delegated parents?

Why JVM parents to adopt mechanisms to delegate to load the class it?

Any of a class, we need to establish its uniqueness in the Java virtual machine by loading its class loader and the class itself together, each class loader has a separate class namespace.

In other words, to determine whether two class "equal", only in these two categories is the premise makes sense to load the same class loader, or even if these two classes a Class from the same file, the same loading a virtual machine, as long as the class loader to load them different, the two classes are not necessarily equal.

Parent delegation model based design, then in Java foundation classes, similar to the Object class Object repeat the question several times would not exist, because the pass through the layers, load request will eventually be in response Bootstrap ClassLoader. Object class will be loaded only one, or if you have written a java.lang.Object class, and put it in the ClassPath, there will be lots of the Object class, so the Java type system, the most basic of behavior can not to ensure that the application will be chaos.

Guess you like

Origin www.cnblogs.com/gaopengpy/p/12202572.html