当前位置:网站首页>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。
边栏推荐
- openEuler 有奖捉虫活动,来参与一下?
- The project manager's "eight interview questions" is equal to a meeting
- Sword finger offer II 013 Sum of two-dimensional submatrix
- LeetCode 535(C#)
- Solve the problem of remote rviz error reporting
- Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses
- 杰理之关于 TWS 交叉配对的配置【篇】
- ASP. Net kindergarten chain management system source code
- 吞吐量Throughout
- Experiment 1 of Compilation Principle: automatic implementation of lexical analyzer (Lex lexical analysis)
猜你喜欢

Openeuler prize catching activities, to participate in?

转置卷积理论解释(输入输出大小分析)

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!!!

九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」

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

【STL】vector

LeetCode_7_5

PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!

Ways to improve the utilization of openeuler resources 01: Introduction
随机推荐
MySQL、sqlserver oracle数据库连接方式
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Specify the version of OpenCV non-standard installation
ant desgin 多选
My creation anniversary
R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
Solve the problem of remote rviz error reporting
时间工具类
杰理之发起对耳配对、回连、开启可发现、可连接的轮循函数【篇】
Implement secondary index with Gaussian redis
9 原子操作类之18罗汉增强
Throughput
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
强化学习-学习笔记8 | Q-learning
what‘s the meaning of inference
openEuler 资源利用率提升之道 01:概论
干货分享|DevExpress v22.1原版帮助文档下载集合
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
what‘s the meaning of inference