Java Class Loader

Source: Internet
Author: User

Java Class Loader
Class loading process

JVM divides the class loading process into three steps

The following three steps are involved:

JVM divides the class loading process into three steps:Load (Load), Link and initialization)The link is divided into three steps, as shown in:


1) load: Find and load binary data of the class;

2) link:

Verification: ensure the correctness of the loaded class. Preparation: allocate memory for the static variable of the class and initialize it as the default value. Resolution: Convert the symbol reference in the class to a direct reference;

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + Mymz9cq8u6 + release/K18/IyOe5 + release + o6zL/L/release/tKqz8i5/release + release/release ++ release + bXEo6zK18/ i19a92sLrzsS8/examples + juw.vcd4kpha + examples/o6y78tXfttS4w76yzKyx5MG/examples = "com. lyj. load ") 5) initialize a subclass of a class (the parent class of the subclass will be initialized first) 6) Startup class of JVM startup time, that is, the class with the same file name and Class Name

Only these 6 conditions will lead to class initialization.


Class Loading

When starting JVM, you can use three class loaders: bootstarp class loaders, extensions class loaders, and application class loaders.


Bootstrap loader: only responsible for loading the core Java library, such Vm. jar and core. jar in the/jre/lib directory. This class loader is the core part of JVM and is written in native code.

Extension Class Loader: responsible for loading the code under the extension path, generally located in /Jre/lib/ext or code in the path specified by the system property of java. ext. dirs. This class loader is implemented by sun. misc. Launcher $ ExtClassLoader.

Application Class Loader: Generally, Java application classes are loaded by them. You can obtain it through ClassLoader. getSystemClassLoader.


If the application Class Loader needs to load a class, it first delegates the extension class loader, And the extension class loader then delegates the bootstrap class loader. If the parent class loader cannot load the class, the subclass loader searches for the class in its own library. Based on this feature, the class loader is only responsible for classes that cannot be loaded by its ancestor.

Summary:

The class loader is an innovation of java. Basically, all class loaders are an instance loaded with java. ClassLoaderler. The basic purpose is to help us understand the Object Instantiation process and object calling.

Related Article

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.