I am so confused about these two class loaders. When talking about the hierarchy of Java class loaders, usually the bootstrap classloader and ext class loader and the third one (system classloader or app classloader) are mentioned.
To be more accurate, I checked the source code of JDK. In class Launcher
, there is the code:
loader = AppClassLoader.getAppClassLoader(extcl);
In class ClassLoader
, the method:
getSystemClassloader()
Also says the system classloader is used to start the application.
So which is the third one in the hierarchy, or are the two classloaders the same?
ClassLoader#getSystemClassloader()
returnsscl
, which is initialized inClassLoader#getSystemClassloader()
and return byLauncher#getClassLoader()
. The returned loader inLauncher#getClassLoader()
isAppClassLoader.getAppClassLoader(extcl)
. So AppClassLoader in Java servers as system class loader.