Class loader architecture and parental delegation mechanism for Java

Source: Internet
Author: User

The ClassLoader loads the bytecode file into memory and generates the corresponding Java.land.class object in the method area as a portal to the external access method area.

Class Loader hierarchy:

        

Boot class loader-------------extension classloader--------------------------Reference program ClassLoader-----------------custom class Loader

1, boot class loader load Jre/lib/rt.jar package load Core class Library

2. The extension loader is responsible for loading Jre/lib/ext/*.jar

3. Load our custom class with the program loader class

4. The custom loader is responsible for loading the specified class

Parent delegation:

Customize a Java.utils.HashMap class with the same package name as the class name, can it be compiled and passed? If the compilation passes, which of the HashMap classes is loaded, why?

Answer: Can be compiled by referencing Java HASHMAP Parent delegation first load Java

Parental delegation mechanism, when the class loader receives a request to load the class, regardless of whether it can load, first load the request to the parent class, if the father has a father, in the upward submission, until the top-level parent class, if the topmost load can be loaded on the load if not loaded, and so on to the son load, and so on, Report an exception if it is not yet loaded

Class loader architecture and parental delegation mechanism for Java

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.