Java Basics-Class loader

Source: Internet
Author: User

to understand the class loader, first understand the loadI. Loading of classes (overview of loading classes)When a program wants to use a class, if the class has not yet been loaded into memory, the system initializes the class by loading, connecting, and initializing three steps.
1. Loading
    1. This means reading the class file into memory and creating a class object for it.
    2. When any class is used, the system creates a class object.

where the class object is the focus of the reflection to be reflected in the next section. This class object describes all of the information about this object, such as what constructs are available, what member methods are available, and what fields are available. 2. Connection
    1. Verify that you have the correct internal structure and that it is consistent with other classes
    2. Prepare to allocate memory for static members of the class and set default initialization values
    3. Resolve to replace a symbolic reference in a class's binary data with a direct reference

3. Initialization

is the initial steps we've talked about before.Class 3.1 Initialization time (class initialization time)
    1. To create an instance of a class
    2. Access static variables for a class, or assign a value to a static variable
    3. To invoke a static method of a class
    4. Use reflection to force the creation of a class or interface corresponding to the Java.lang.Class object (this is reflection, the reverse load Class)
    5. Initializes a subclass of a class
    6. To run a main class directly using the Java.exe command
second, class loader1. Class loader
    1. Responsible for loading the. class file into memory and generating the corresponding class object for it.
    2. Although we do not need to care about the class loading mechanism, we understand this mechanism and we can better understand the operation of the program.
2, the composition of the class loader
    1. Bootstrap ClassLoader Root class Loader
    2. Extension ClassLoader Extension Class loader
    3. Sysetm ClassLoader System Class Loader
3, the Role of class loader3.1 Bootstrap ClassLoader root class loaderalso known as the Boot class loader, which is responsible for loading Java core classes
such as system,string and so on. In the Rt.jar file under the Lib directory of the JRE in the JDK
3.2 Extension ClassLoader extension class loaderresponsible for loading the jar packages in the extended directory of the JRE.
The Lib directory of the JRE in the JDK under the EXT directory
3.3 System ClassLoader class loaderresponsible for loading the class file from the Java command when the JVM starts, and the jar package and classpath specified by the CLASSPATH environment variable

Java Basics-Class loader

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.