Understanding of Java class loading

Source: Internet
Author: User

There are three stages of Java load exhaustion:

1. Load stage: When encountering a static member including a method in the new Access class, the JVM class loader is prompted to load the class into memory (binary bytecode file). Nothing else is to be done. Example: Object.class simply loads the class into memory. No other action was taken.

2. Link stage: The Non-Object.class method (known only to this point) to access the information of the class, will enter the link stage, in which the domain in the class will be allocated memory, assigned to the class domain (member) default value (only the class domain has a default value), if necessary, the domain will be resolved, such as a field to add a symbol "=", the right value is parsed and a reference to the object is created that the object is a reference type.

3. Initialization phase: If the class is encountered when the class has a superclass (base class, parent Class), then the first three steps to its parent class. The static initialization block is then executed (once only) and the static initialization method (if necessary).

4. Class initialization complete

Attention:

There is no need to initialize a class for static compile-time constants (static final) (non-static must be new to access, and so on when your new comes out of the initial completion) for access.

What is a compile-time constant?

Compile-time constants are the amount at compile time there is already a determined value, in Java static constants must be initialized, in the static initialization block, static construction method if there are multiple construction methods, it must be in each of the construction method to display the initialization.

If anyone sees, there is nothing wrong with the place, trouble message advice.

Understanding of Java class 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.