The life cycle of Java classes _ mechanism

Source: Internet
Author: User

The life cycle of a class:

after a class has been compiled, the next step is to start using the class, and if you want to use a class, you can't do without JVM . In program execution , the JVM is completed by loading, linking, and initializing these 3 steps.

The loading of the class is done through the ClassLoader, and the loader will . Class Binary file loading of files JVM and create a description of the class in the heap area . Java.lang.Class object. Used to encapsulate data. but the same class will only be loaded by the class loader before

A link is the ability to assemble binary data into a functioning state.

links are divided into calibration, preparation, parsing this 3 Stages of

a checksum is used to verify that the binary is suitable for the current JVM (version),

Preparation is the allocation of memory space for static members. and set the default value

Parsing refers to the process of converting code in a constant pool as a direct reference, until all symbolic references can be used by the running program (establishing a complete correspondence relationship)

After completion, the type is initialized, and after initialization the object of the class can be used normally until an object is no longer in use and will be garbage collected. Free up space.

when no reference is directed to the Class object is unloaded, ending the life cycle of the class

Life cycle of Java classes _ mechanism

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.