26_ custom system class loader underlying source code analysis methods and analysis forName

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_43277087/article/details/102752591

Source:
Here Insert Picture Description
getting APPClassLoader, incoming extcl, as his parents
Here Insert Picture Description
Here Insert Picture Description
figure above, set the thread context class loader currently executing, that is, APPClassLoader

Here Insert Picture Description
The figure above, the security manager of some code

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
The application is returned class loader

Here Insert Picture Description

In the ClassLoader
Here Insert Picture Description
class ClassLoader
Here Insert Picture Description
Here Insert Picture Description
above it can be seen that, if (cls! = Null) That is, you can set their own class loader used as a system class loader.
There constructor parameters invoked by reflection custom system class loader, parameters ClassLoader
Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description
This is the reason for loading custom placed this configuration method, the method in order to make the reflection in the run method of the ClassLoader call SystemClassLoaderAction

Here Insert Picture Description
split line------------------------------------------------ ---------------------------
analytical method forName Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
forName:
Here Insert Picture Description
return of the caller is calling forName method of that class
returned ccl method is to call forName that kind of class loader

For example: a custom class, called forName (database-driven jdbc link or something)
then the caller is my custom class
ccl class loader is to load my class

Here Insert Picture Description
Look at this
Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_43277087/article/details/102752591