Java Foundation-JVM class loading mechanism

Source: Internet
Author: User

The class loading of the JVM is done through ClassLoader and its subclasses, and the hierarchy and loading order of the classes can be described as follows:

1) Bootstrap ClassLoader/Start class loader

$JAVA _homeAll classes in JRE/lib/rt.jar, implemented by C + +, are not classloader subclasses

2) Extension classloader/Extension class loader

Some jar packages that are responsible for loading the extensions in the JAVA platform, including the jar packages in the specified directory of the JRE/lib/*.jar or-djava.ext.dirs in the $JAVA _home

3) App classloader/System class Loader

Responsible for documenting the jar packages specified in the Classpath and the class in the directory

4) Custom classloader/user-defined class loader (subclass of Java.lang.ClassLoader)

The ClassLoader that the application customizes according to its own needs, such as Tomcat and JBoss, will be implemented according to the Java EE specification itself ClassLoader

The load process checks to see if the class is loaded, the check order is bottom-up, and the custom ClassLoader to bootstrap ClassLoader-by-layer check, as long as a certain classloader is loaded as if the class has been loaded. Ensure that only all classloader of this class are loaded once. The order of loading is top-down, that is, the upper layer tries to load the class one at a level.

Introduction and analysis of class loading parental delegation mechanism

Here, it should be emphasized that the JVM defaults to the parent delegation mechanism when loading the class. In layman's words, when a particular class loader receives a request to load a class, it first delegates the load task to the parent class loader, recursively, and returns if the parent ClassLoader can complete the class load task, only to load itself when the parent ClassLoader cannot complete the load task.

Java Foundation-JVM class loading mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.