user3690370 user3690370 - 7 months ago 14
Apache Configuration Question

Why Bootstrap class of Apache tomcat calls ClassLoader.loadclass instead of new operator?

I was going through apache tomcat opensource code, and at the start, in i found this:

Class<?> startupClass = catalinaLoader.loadClass("org.apache.catalina.startup.Catalina");

even when and this belongs to the same package, Why Bootstrap(org.apache.catalina.startup) class of apache tomcat calls ClassLoader.loadclass to load Catalina class(org.apache.catalina.startup.Catalina) and then class.newInstance, why not it just create Catalina instance using new operator?


Since the code uses explicitly catalinaLoader and assuming it later creates an instance of the class, it's to make sure that the Catalina class is loaded with a different classloader than the Bootstrap class.

For further information what this means, refer to documentation about class loading.