Uttar Pradesh, India
Instagram
image

ClassLoader Loading Mechanism

Java ClassLoaders works on a delegation mechanism. The basic and important idea behind it that every class loader has a parent class so class loader loads("delegates") parent class first before loading the class itself.  Here are some highlights features in the delegation mechanism:    

 

1-The loadClass() method in ClassLoader performs these below tasks  >If a class has already been loaded, it returns the class.  >Otherwise, it delegates the search for the new class to the parent class loader.  >If the parent class loader does not find the class, loadClass calls the method findClass() to find and load the required class.

 2-The findClass() method of ClassLoader searches for the class in the current class loader if the class wasn't found by the parent class loader.    

3-The class java.net.URLClassLoader serves as the basic class loader for extensions and other JAR files searches, overriding the findClass method of java.lang.ClassLoader to search one or more specified URLs for classes and other resources.    The below figure gives the complete structure of the delegation model


Comments

Share your thoughts in the comments

Your email address will not be published. Required fields are marked *