当前位置:网站首页>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 .
边栏推荐
- [hand tear STL] BitSet (bitmap), bloom filter
- 手机端微信发朋友圈功能测试点总结
- Redis为何选择单线程?
- 关于接口测试你想知道的都在这儿了
- Application of breakthrough thinking in testing work
- ansible+Crontab批部署巡检
- The technical aspects of ByteDance are all over, but the result is still brushed. Ask HR why...
- Imitation Tiktok homepage interface
- 在进行自动化测试,遇到验证码的问题,怎么办?
- zigbee开发板(nxpzigbee开发)
猜你喜欢

在进行自动化测试,遇到验证码的问题,怎么办?

Flex layout

微信发卡小程序源码-自动发卡小程序源码-带流量主功能
![[Fantan] how to design a test platform?](/img/54/5aca54c0e66f8a7c1c3215b8f06613.png)
[Fantan] how to design a test platform?

少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月

虚拟内存与磁盘

还不懂mock测试?一篇文章带你熟悉mock

6-18漏洞利用-后门连接

kubernetes之VictoriaMetrics单节点

Children's programming electronic society graphical programming level examination scratch level 1 real problem analysis (judgment question) June 2022
随机推荐
在腾讯干软件测试3年,7月无情被辞,想给划水的兄弟提个醒...
什么是类加载?类加载的过程?
Jmeter--- set proxy recording request
jenkins+SVN配置
文件无法保存(文件夹已损坏无法读取怎么办)
C语言:随机生成数+选择排序
6-17 vulnerability exploitation - deserialization remote command execution vulnerability
The dragon lizard exhibition area plays a new trick this time. Let's see whose DNA moved?
kubernetes之VictoriaMetrics单节点
磁盘空间的三种分配方式
How to implement an app application to limit users' time use?
2022 the latest software tests eight part essay. Whether you can offer depends on how you recite it
The technical aspects of ByteDance are all over, but the result is still brushed. Ask HR why...
Is there any document for synchronizing from Oracle to ODPs?
若依如何解决导出使用下载插件出现异常?
Detailed summary of C language game dual cache to solve the flash screen problem [easy to understand]
Uninstall NPM and install NPM_ Use 'NPM uninstall' to uninstall the NPM package 'recommended collection'
golang : MVC之models
JS timer and swiper plug-in
2022最新软件测试八股文,能不能拿心仪Offer就看你背得怎样了