当前位置:网站首页>JVM easy start-01
JVM easy start-01
2022-06-23 10:25:00 【cfcoolya】
One . Study JVM The benefits of
- Be able to understand why Java The earliest is called interpretative language
- In order to better solve online troubleshooting problems in the future
- Can be adjusted by JVM Relevant parameters are improved Java Application performance
- It's clear that Java How the program is executed
Two .JVM Architecture diagram

3、 ... and . Class loader ClassLoader
3.1 Class loading 、 Connect 、 initialization
First, let's explore a class loaded into JVM A basic structure of :
class Enter class loader , Load initialization as class template , Instantiate as instances of classes .

Understand from code :
class Test{
public static int a = 1;
}// What is given in our program is public static int a = 1;
// However, the steps in the loading process are as follows :
1. Loading phase The compiled file is .class file , Then load... Through the class , Load into JVM【 Find and load the binary data of the class 】
2. Connection phase
First step ( verification ): Make sure Class Class files are OK 【 Make sure the class being loaded is correct 】
The second step ( Get ready ): Initialize to a=0.( Because of you int The initial value of the type is 0) 【 Allocate memory for static variables of a class , And initialize it to the default value 】
The third step ( analysis ): Convert reference to direct reference 【 Convert symbolic references in a class to direct references 】
3. Initialization phase : Through this parsing stage , hold 1 Assign to variable a3.2 Classification of class loaders
- BootstrapClassLoader( Root loader )sun.boot.class.path Load the package of the system , Package line jdk Classes in the core library
- ExtensionClassLoader( Extend the classloader )java.ext.dirs Load extension jar The class in the package
- AppClassLoader( Application class loader )java.class.path Load the classes you write , Compiled classes
- Java.long.ClassLoader Subclasses of , The user can customize the loading method of the class

3.3 Parent delegate mechanism
How the parental delegation mechanism works :
Let the parent class load layer by layer , The topmost parent class cannot be loaded down , By analogy .
- Class loader received a class load request
- Delegate this request all the way up , Until the root class loader ( Start the loader )
- The class loader checks to see if it can load , Load as soon as you can , Otherwise, notify the child loader to load
- Repeat step 3
public class ClassLoaderDemo {
public static void main(String[] args) {
System.out.println("ClassLodarDemo's ClassLoader is " +ClassLoaderDemo.class.getClassLoader());
System.out.println("The Parent of ClassLodarDemo's ClassLoader is " +
ClassLoaderDemo.class.getClassLoader().getParent());
System.out.println("The GrandParent of ClassLodarDemo's ClassLoader is " +
ClassLoaderDemo.class.getClassLoader().getParent().getParent());
}
}
ClassLodarDemo's ClassLoader is [email protected]
The Parent of ClassLodarDemo's ClassLoader is [email protected]
The GrandParent of ClassLodarDemo's ClassLoader is nullbenefits :
To ensure the Java The documentation of the program runs , Avoid duplicate loading of classes
To ensure the Java At the heart of API Not tampered with
Learning comes from :B standing - Madness theory
边栏推荐
- 开发者,你对云计算可能有些误解
- 2021-05-11 static keyword
- 2021-05-07封装 继承 super this
- 同花顺是炒股的么?在线开户安全么?
- Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry
- Unity技术手册 - 生命周期LifetimebyEmitterSpeed-周期内颜色ColorOverLifetime-速度颜色ColorBySpeed
- Golang quick start (1)
- NOI OJ 1.4 01:判断数正负 C语言
- 2021-05-10 method rewrite polymorphism considerations
- thymeleaf中如何给onclick事件传值的方法
猜你喜欢

Copilot免费时代结束!正式版67元/月,学生党和热门开源项目维护者可白嫖

陆奇首次出手投资量子计算

谷贱伤农,薪贱伤码农!

Build the information and innovation industry ecology, and make mobile cloud based on the whole stack of independent innovation

SQL writing problem to calculate the ring ratio of the current month and the previous month

R和RStudio下载安装详细步骤

Go string comparison

AI芯片技术-2022年

Unity技术手册 - 生命周期内速度限制(Limit Velocity Over Lifetime)子模块和速度继承(Inherit Velocity)子模块

Confessing with Snake games (with source code)
随机推荐
Three implementation methods of distributed lock
Confessing with Snake games (with source code)
NOI OJ 1.2 整型与布尔型的转换 C语言
NOI OJ 1.3 17:计算三角形面积 C语言
文献综述怎么写 ,一直没头绪写不出来怎么办?
Tencent tangdaosheng: practice "science and technology for the good" and promote sustainable social value innovation
laravel8 beanstalk 使用说明
Five SQL functions for operation date that must be known in SQL tutorial
解决预览pdf不能下载的问题
2021-04-16 array
Golang quick start (1)
R和RStudio下载安装详细步骤
NOI OJ 1.3 09:与圆相关的计算 C语言
thymeleaf如何取url中请求参数值?
thymeleaf中如何给onclick事件传值的方法
pycharm安装教程,超详细
AI芯片技术-2022年
NOI OJ 1.4 05:整数大小比较 C语言
2021-05-12 interface definition and Implementation
MySQL optimistic lock and pessimistic lock