当前位置:网站首页>Class loading process of JVM
Class loading process of JVM
2022-06-21 21:00:00 【Swarford】
1. load
java After the source code is compiled into bytecode , Then the bytecode is loaded into the method area through the class loader , And according to Class File descriptions are created in the heap java.lang.Class object
2. link
2.1. verification :
Verify whether bytecode conforms to virtual machine specification , If it is illegal, an error will be reported ClassFormatError
2.2. Get ready :
2. by static Static variables allocate space , Set the default value
JDK1.6 Static variables in the method area , current JDK1.8 Static variables in the heap
static Allocating space and assigning values to static variables are two steps , The allocation of space is done in the preparation phase , The assignment is done in the construction of the initialization stage class
· If it is static final The basic type is special , Values are determined at compile time , Assignment is done in preparation
· If it is static final Reference type , Then the assignment is also done in the initialization phase
2.3. analysis :
This refers to resolving a symbolic reference in a constant pool to a direct reference ,
Symbol references are just symbols , Don't know class 、 Method in memory , But after parsing , You know the class 、 The exact location of the method in memory
loadClasss() Method load only , But it will not lead to class resolution and initialization
new() Can do parsing and initialization
3. initialization
Initialization is to execute the constructor of a class , The virtual machine guarantees the thread safety of the constructor of this class
When it happened :
Initialization is lazy
main Method time is initialized first
First access to static variables of this class ( No final Of ), Static method
Initialization of subclasses : If the parent class has not been initialized, the parent class will be initialized first
Subclasses access static variables of the parent class , Only the initialization of the parent class will be triggered , Subclasses are not initialized
Class.forName Will cause class initialization (newInstacnce() Method will perform a parameterless construction )
new() Object causes initialization
Will not cause initialization :
visit static final static const ( Basic types 、 character string ) Initialization will not be triggered , They all complete the assignment of variables in the link preparation stage
Use ClassLoader default loadClass Method does not trigger the initialization of the class when it loads the class
Creating an array of classes does not result in initialization
When a subclass refers to a static field of a parent class , Does not trigger subclass initialization , Only the initialization of the parent class will be triggered .
loadClasss() Method load only , But it will not lead to class resolution and initialization
边栏推荐
- 机器学习之数据处理与可视化【鸢尾花数据分类|特征属性比较】
- Post Gartner webinar "nine questions on digital transformation"
- Vector expansion mechanism of STL
- Vertical and horizontal network shooting range community Modbus Protocol
- 数据路:三人行,必有我师!
- 什么是eGFP,绿色荧光蛋白
- STL之vector扩容机制
- Analysis of ${} string splicing in JS
- YX2811景观装鉓驱动IC
- 决策树(Decision Tree)学习笔记
猜你喜欢
![[专利与论文-20]:江苏省南京市2022年电子信息申报操作指南](/img/bb/313f4a9f9c03ab2e9dfe0e8846831e.png)
[专利与论文-20]:江苏省南京市2022年电子信息申报操作指南

【并行与分布式计算】10b_MapReduce GFS Implementation

What noteworthy technologies of gold: the importance of fund management

The Summer Challenge realizes a standard layout of Huawei app with openharmony ETS

同步升压 DC/DC 转换器FS3400同步SOT23-6小电流500MA升压ic

Pfsense configuring tinc site to site tunneling tutorial

C端添加Traceid的最终的方案

什么是GCaMP6f?钙离子成像技术。

欢迎使用Markdown编辑器

The difference between break and continue
随机推荐
[summary of smart trash cans based on Hetai ht32f52352]
Shutter tabbarview component
NS32F103VBT6软硬件替代STM32F103VBT6
LeeCode70 爬楼梯
pc 电商平台----search模块
History of the Great Game
运维监控数据可视化-让数据自己会说话[华汇数据]
带你区分几种并行
异步方法 理解(demo附代码)
IAR major upgrade, support vs code, St release the first sensor with processing unit
How functions are declared
起飞,年薪40万+
Alibaba cloud ack one and ACK cloud native AI suite have been newly released to meet the needs of the end of the computing era
亿腾医药在港招股书第三次“失效”:上市实质延后,红杉等为股东
Rongyun obtains token
Show you how to distinguish several kinds of parallelism
Ns32f103vbt6 hardware and software replace stm32f103vbt6
Servlet usage
The highest monthly salary is 17k. As long as there is a field of hope in your heart, hard work will usher in a green land~
How to use memcached to implement Django project caching