Learn more about Java Virtual machine---class loading mechanism----loading

Source: Internet
Author: User

Loading is a phase of class loading. Don't get confused.

This phase mainly does the following three things.
1. Get the binary stream of this class through the fully qualified name of a class

2. Convert the static storage structure represented by this binary stream into the runtime data structure of the method area

3. Generate the Java.lang.Class object in memory as an access entry

. Gets the binary stream of this class through the fully qualified name of a class: This step is not clear, how to get it. The Java virtual machine is not specified. So there's a lot of ways to get it.

1. Get from the Zip,jar,war package

2. Getting from the network

3. Runtime generation, such as dynamic proxy

4. Other files are generated such as JSP

5. Obtained from the database, which I do not understand. Just leave it.

Loading is divided into loading non-array classes and arrays of classes:

Load non-array classes, you can use the system's class loader, or you can customize the class loader (that is, override the LoadClass () method)

Load the array class, the component type of the array when the reference class is recursively loaded with this component type. The array is identified on the class name space of the class loader for the class

The array's component type is not a reference class (such as int[]), then the array is associated with the Boot class loader

By the way

The visibility of an array class is consistent with the visibility of the component type, and the component type is not a reference type and is directly default to public

After the load is complete, the binary byte stream is stored in the method area, and then the Java.lang.Class object is generated in the heap.

In the end, the loading and joining sections are interleaved, but the load is still in front of the connection

Learn more about Java Virtual machine---class loading mechanism----loading

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.