当前位置:网站首页>What is class loading? Class loading process?
What is class loading? Class loading process?
2022-07-25 22:09:00 【Hua Weiyun】
What is class loading ? The process of class loading ?
The virtual machine loads the data describing the class into memory , And verify the data 、 Parse and initialize , Finally, it can be used directly by virtual machine class object ;
The entire life cycle of a class includes : load (Loading)、 verification (Verification)、 Get ready (Preparation)、 analysis (Resolution)、 initialization (Initialization)、 Use (Using) And uninstall (Unloading)7 Stages . And prepare for 、 verification 、 analysis 3 The parts are collectively called connections (Linking).
load 、 verification 、 Get ready 、 Initialize and uninstall this 5 The order of the stages is fixed , The loading process of a class must start step by step in this order , The parsing phase is not necessarily : It can in some cases start after the initialization phase , This is to support Java Language runtime binding ( Also known as dynamic binding or late binding )
Class loading process is as follows :
load , There are three steps to loading : 1、 Get the binary stream of a class by its fully qualified class name ; 2、 The static storage structure of the binary stream is transformed into the runtime data structure of the method area ; 3、 Generate a... For this class in the heap class object ;
verification : Verify the class The byte stream information in the file meets the requirements of virtual machine , It doesn't threaten jvm The safety of the ;
Get ready : by class Object to allocate memory , Initialize its initial value ;
analysis : In this stage, the symbol reference is transformed into direct reference ;
initialization : It's time to initialize , Just start executing the java Code ; The initialization phase is the process of calling the class constructor ;
What is a class loader , What are the common class loaders ?
Class loaders are : Getting the binary byte stream of a class by its fully qualified class name is called class loader ; There are four types of class loaders :
Start class loader (BootStrapClassLoader): Used to load java The core library , Can't be java The program directly refers to ;
Extend the classloader (Extension ClassLoader): Used to load java Extension library for ,java The virtual machine implementation of will provide an extension Library Directory , This kind of loader looks up and loads in the extension library directory java class ;
system class loader (AppClassLoader): It is based on java Class path to load the class , Generally speaking ,java Application classes are loaded through it ;
Custom class loaders : from java Language implementation , Inherited from ClassLoader;
What is the parent delegate model ? Why do I need a parental delegation model ?
When a class loader receives a request to load a class , He doesn't try to load it himself in the first place , Instead, delegate the request to the parent loader to load it , Only when the parent class loader cannot find the given class in its own search scope class , The child loader will try to load the class by itself ;
To prevent multiple identical bytecodes in memory ; Because if there's no parental appointment , Users can define a java.lang.String class , Then there is no guarantee of the uniqueness of the class .
Add : So how to break the parental delegation model ?
Custom class loaders , Inherit ClassLoader class , rewrite loadClass Methods and findClass Method .
边栏推荐
- Victoriametrics single node of kubernetes
- 数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir
- Minor GC 和 Full GC 有什么不同呢?
- 磁盘空间的三种分配方式
- 【GO基础02】第一个程序
- [fan Tan] after the arrival of Web3.0, where should testers go? (ten predictions and suggestions)
- 6-18 vulnerability exploitation - backdoor connection
- ansible+Crontab批部署巡检
- 2022 love analysis ― bank digitalization practice report
- Unity performance optimization direction
猜你喜欢

2022 the latest software tests eight part essay. Whether you can offer depends on how you recite it

TFrecord写入与读取
![[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality](/img/11/42c4674d23ee93850fb3d2de0d0932.png)
[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality "eye edge" during interview)

面了个腾讯三年经验的测试员,让我见识到了真正的测试天花板

2day

Basic knowledge in the project

Imitation Tiktok homepage interface

Nuclear power plants strive to maintain safety in the heat wave sweeping Europe

Don't vote, software testing posts are saturated

2 lines of code to generate a solid desktop background
随机推荐
关于接口测试你想知道的都在这儿了
Uninstall NPM and install NPM_ Use 'NPM uninstall' to uninstall the NPM package 'recommended collection'
磁盘空间的三种分配方式
Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
Golang: MVC models
JS timer and swiper plug-in
[fan Tan] in detail: lower control, upward management, upward drawing cake.
How to implement an app application to limit users' time use?
Redis usage details
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No suc
[Fantan] how to design a test platform?
Wet- a good choice for people with English difficulties - console translation
YUV420 YUV420sp 图像格式「建议收藏」
别投了,软件测试岗位饱和了...
字节跳动技术面都过了,结果还是被刷了,问HR原因竟是。。。
TFrecord写入与读取
What should I do if I encounter the problem of verification code during automatic testing?
Don't vote, software testing posts are saturated
2 lines of code to generate a solid desktop background
如何实现一个App应用程序,限制用户时间使用?