Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of class loading mechanism in Java?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Java class loading mechanism in what is the principle, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Load, connect (verify preparation for parsing), initialization phase

Load: get the binary byte stream of the class according to the fully qualified name of the class; convert the static storage structure represented by the byte stream into the dynamic storage structure in the method area; generate a java.lang.Class object that represents the class in memory as the access entry for the class in the method area.

Verify (connect): make sure that the loaded class information conforms to the jvm specification and there are no security issues

Prepare (connect): allocate memory and set initial values for class variables in the allocated memory method area

Parsing (connecting): the process of converting symbolic references in a constant pool to direct references

Initialization: the initialization phase is the process of executing the class constructor clinit () method. This method is generated by the compiler automatically collecting the assignment actions of all class variables in the class and combining static statement blocks. And ensure that the clinit method of the parent class is called before the clinit call of the subclass. With the exception of the interface, if a class implements the interface, the clinit method of the class is executed, and the clinit method of the interface is not executed. Because clinit methods may not exist, such as interfaces without static statement blocks and class variables.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report