How to break the parent delegation mechanism?

        Java allows developers to customize class loaders.

        There are two methods in ClassLoader are findClass() and loadClass() methods, they are not final modified, so subclasses can be rewritten.

        Because after JDK1.2, the core code of the parental delegation mechanism is in the loadClass() method, so we do not recommend rewriting the loadClass() method (to prevent damage ), but rewriting the findClass() method to implement custom class loading to break the parental delegation mechanism.

        For example, tomcat uses a self-defined class loader. When our project is deployed to tomcat, the runtime is loaded by the class loader in tomcat.

Guess you like

Origin blog.csdn.net/m0_62565675/article/details/131768878