Dark Horse programmer-Class Loader

Source: Internet
Author: User

--------------------- Android training, Java training, and hope to communicate with you! ---------------------- Class Loader
1. Overview
Classes in Java need to be loaded into the memory (to become bytecode, that is, Class Object. Generally, the class loader is also a Java class and also needs to be loaded by the loader. Therefore, there must be a non-Java class loader in Java to load these loaders, it is Bootstrap. Other loaders are Java classes, such as extclassloader, appclassloader, and self-defined loaders. Their relationships are as follows:
Bootstrap is the parent of extclassloader. It is used to load the class file in JRE/lib/RT. jar, that is, the system class.
Extclassloader is the parent of appclassloader, used to load the class in JRE/lib/EXT/*. jar, that is, the extension class
Appclassloader is the parent of the custom loader. It is used to load the specified jar or directory of classpath.
The custom class loader is used to load classes in a specified directory.

2. Delegation mechanism of the Class Loader
When the class loader loads a class, it first delegates the parent (parent) to complete it. If the parent can complete it, you don't have to do it yourself. This solution avoids repeated loading of the same class, resulting in multiple bytecode of the same class.

3. Custom Class Loader
Class myclassloader extends classloader
{
... (You need to override the findclass method to load the class using your own method)
}
Classloader is a subclass of the abstract class classloader. classloader uses the template design mode to expose uncertain parts of the class to the subclass, for example, the findclass method here is the custom part.

-------------------- Android training, Java training, and hope to communicate with you! ---------------------- For details, please refer to: http://edu.csdn.net/heima

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.