当前位置:网站首页>JVM class loading mechanism
JVM class loading mechanism
2022-06-27 06:03:00 【The season when the monsoon dies】
One 、 Class loading steps
JVM Lazy loading mechanism is adopted , That is, only classes are loaded when they are used . Class loading can be divided into the following steps :
load : That is, load the class bytecode file into memory , In the next step, a class representing this class will be generated in memory java.lang.Class object , As the access to all kinds of data of this class in method area .
verification : Verify the accuracy of bytecode files , Each bytecode file has a fixed format , To verify whether the bytecode file is damaged .
Get ready : Allocate memory space to static variables and assign default values .
analysis : take Symbol reference Replace with direct reference , This stage will put some static methods ( Symbol reference , such as main() Method ) Replace with a pointer or handle to the memory where the data is located ( Direct reference ), This is called static linking The process ( Finished during class loading ), Dynamic links It's done during the running of the program, replacing symbol references with direct references .
initialization : Initialize assignment to class variable , And execute the static code block .
Two 、 Class loader
JVM There are mainly four types of loaders to complete the class loading of .
3、 ... and 、 Class loading mechanism
JVM The class loading mechanism of is a parental delegation mechanism , When loading a class , If you use a custom class loader , Then check whether the custom loader has loaded this class , If not, delegate the upper application class loader to load , At loading time , Similarly, check whether the current class loader has loaded this class , If not, delegate the upper extension class loader to load . At loading time , Similarly, check whether the current class loader has loaded this class , If not, it will be loaded by the upper boot class loader , At loading time , Similarly, check whether the current class loader has loaded this class , without , The boot class loader loads this class , If the class is not loaded under the path governed by the boot class loader , There is a lower level extension program class loader to load , If the class is not loaded under the path governed by the extended class loader , There is a lower level application class loader to load ; If the class is not loaded under the path governed by the application class loader , There is a lower level custom class loader to load ; If it cannot be loaded again, an exception will be thrown . It can be summed up as a sentence : Check whether the class has been loaded from the bottom up , Load classes from top to bottom .
Four 、 The significance of parental delegation mechanism
5、 ... and 、 Overall responsibility for the delegation mechanism
6、 ... and 、Tomcat Break the parental delegation mechanism
tomcat Why not use a parental delegation mechanism ?
One tomcat It is possible to run multiple applications , And the multiple applications refer to different versions of the same class , therefore , The feature of ensuring that the class only loads one copy from the parent delegation mechanism does not conform to tomcat Business scenario requirements .
tomcat How to ensure jps Hot loading of ?
边栏推荐
猜你喜欢
Asp. Net core6 websocket simple case
Kubesphere cluster configuration NFS storage solution - favorite
使用 WordPress快速个人建站指南
Formation and release of function stack frame
Dual position relay dls-34a dc0.5a 220VDC
函数栈帧的形成与释放
Software testing year end summary report template
427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)
使用CSDN 开发云搭建导航网站
多线程基础部分Part2
随机推荐
Opencv实现对象跟踪
多线程基础部分Part 1
LeetCode 0086.分隔链表
The form verifies the variables bound to the V-model, and the solution to invalid verification
程序猿学习抖音短视频制作
Double position relay rxmd2-1mrk001984 dc220v
[cocos creator 3.5.1] addition of coordinates
JVM调优思路
Redis4.0新特性-主动内存碎片整理
Formation and release of function stack frame
Spark 之 WholeStageCodegen
汇编语言-王爽 第11章 标志寄存器-笔记
Unity中跨平台获取系统音量
My opinion on test team construction
Free SSH and telnet client putty
Spark 之 Projection
Senior [Software Test Engineer] learning route and necessary knowledge points
QListWidgetItem上附加widget
Multithreading basic Part3
Get system volume across platforms in unity