Java class loading mechanism and java Loading Mechanism

Source: Internet
Author: User

Java class loading mechanism and java Loading Mechanism

In java, class files are loaded through JVM. class loading methods include implicit loading and explicit loading. When an object is created through the new method during implicit loading, the corresponding class files are implicitly loaded to the JVM through the class loader. The class. forName () method is used to explicitly load the required class files to the JVM.

In java, classes are dynamically loaded. Instead of loading all class files to the JVM at a time, the basic class is first loaded to the JVM, other user classes are loaded into JVM when needed.

In java, classes can be divided into three categories: system class, extension class, and custom class. Different class loaders are provided for these three types of files.

Bootstrap Loader-responsible for Loading System Classes

ExtClass Loader -- responsible for loading extension classes

AppClassLoader-responsible for loading application classes

 

The class loading process consists of the following steps: (For details, refer to "deep understanding of Java Virtual Machine")

1. Load: Find the corresponding class file based on the search path and import it.

2. Link: links can be divided into three steps.

(1) Check: Check the correctness of the class file to be loaded

(2) preparation: allocate the static variables in the class to the memory space.

(3) parsing: Resolve a symbolic reference to a direct reference

3. Initialization: Initialize static variables and static code blocks.

 

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.