当前位置:网站首页>JVM 类加载机制
JVM 类加载机制
2022-07-07 17:52:00 【whiteye太白】
类加载机制
加载 —> 连接(验证 -> 准备 -> 解析)—> 初始化 —> 使用 —> 卸载
1. 加载
- 通过全类名获取定义此类的二进制字节流
- 将字节流所代表的静态存储结构转换为方法区的运行时数据结构
- 在内存中生成一个代表该类的 Class 对象,作为方法区这些数据的访问入口
2. 验证
- class文件格式验证:class文件规范
- 元数据验证:语义分析,是否符合java语言规范
- 字节码验证:操作指令合法
- 符号引用验证:确保解析动作正确执行
3. 准备
为类的静态变量分配内存,并将其初始化为默认值。
(不是赋初值,final 关键字修饰的静态常量则直接赋初值,加载到方法区运行时常量池。)
4. 解析
将常量池内的符号引用替换为直接引用的过程。
5.初始化
为类的静态变量赋予正确的初始值,JVM负责对类进行初始化,主要对类变量进行初始化。
初始化类触发: new实例对象、访问类的静态变量、调用类的静态方法、反射调用类、子类需初始化时先初始化父类(接口同样)、mian方法类。
6. 卸载
- 该类的所有的实例对象都已被 GC,也就是说堆不存在该类的实例对象。
- 该类没有在任何地方被引用。
- 该类的类加载器的实例已被 GC。
边栏推荐
- 爬虫实战(七):爬王者英雄图片
- ant desgin 多选
- 杰理之关于 TWS 配对方式配置【篇】
- L1-027 rental (Lua)
- Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
- Semantic slam source code analysis
- The project manager's "eight interview questions" is equal to a meeting
- Jürgen Schmidhuber回顾LSTM论文等发表25周年:Long Short-Term Memory. All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversarial RL. Soccer learn
- Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
- 2022.07.05
猜你喜欢

Detailed explanation of Flink parallelism and slot
![最多可以参加的会议数目[贪心 + 优先队列]](/img/f3/e8e939e0393efc404cc159d7d33364.png)
最多可以参加的会议数目[贪心 + 优先队列]

Openeuler prize catching activities, to participate in?

Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog
![[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer](/img/7d/ed9a5c536b4cc1913fb69640afb98d.png)
[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer

编译器优化那些事儿(4):归纳变量

PMP practice once a day | don't get lost in the exam -7.7

Ways to improve the utilization of openeuler resources 01: Introduction

一张图深入的理解FP/FN/Precision/Recall

Matplotlib drawing 3D graphics
随机推荐
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
# 欢迎使用Markdown编辑器
tp6 实现佣金排行榜
R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
歌单11111
微信公众号OAuth2.0授权登录并显示用户信息
L1-028 judging prime number (Lua)
关于ssh登录时卡顿30s左右的问题调试处理
9 atomic operation class 18 Rohan enhancement
Unable to link the remote redis server (solution 100%
杰理之开机自动配对【篇】
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
AD域组策略管理
ASP.NET体育馆综合会员管理系统源码,免费分享
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
项目经理『面试八问』,看了等于会了
PMP每日一练 | 考试不迷路-7.7
A pot of stew, a collection of common commands of NPM and yarn cnpm
多个线程之间如何协同
8 CAS