当前位置:网站首页>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 ?

边栏推荐
猜你喜欢

Double position relay jdp-1440/dc110v

多线程基础部分Part2

信息系统项目管理师---第七章 项目成本管理

Thinking technology: how to solve the dilemma in work and life?

Assembly language - Wang Shuang Chapter 13 int instruction - Notes

IAR Systems全面支持芯驰科技9系列芯片

Using domain name forwarding mqtt protocol, pit avoidance Guide

免费的 SSH 和 Telnet 客户端PuTTY

JVM整体结构解析

【QT小作】使用结构体数据生成读写配置文件代码
随机推荐
洛谷P2939 [USACO09FEB]Revamping Trails G 题解
LeetCode 0086.分隔链表
Wechat applet websocket use case
427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)
Codeforces Round #802 (Div. 2)
代码即数据
30 SCM common problems and solutions!
The SCP command is used in the expect script. The perfect solution to the problem that the SCP command in the expect script cannot obtain the value
Two position relay xjls-8g/220
【QT小记】QT元对象系统简单认识
C language implementation timer
leetcode299周赛记录
函数式 连续式
汇编语言-王爽 第8章 数据处理的两个基本问题-笔记
G1和ZGC垃圾收集器
Sqlsever 字段相乘后保留2位小数
Jump details of item -h5 list, and realize the function of not refreshing when backing up, and refreshing when modifying data (record scroll bar)
Program ape learning Tiktok short video production
Asp.Net Core6 WebSocket 简单案例
Built in functions of spark