当前位置:网站首页>JVM virtual machine
JVM virtual machine
2022-06-12 09:15:00 【Java supernatural Road】
1.JVM Class loading process
java Class loading process : load –> verification –> Get ready –> analysis –> initialization , Then the class can be used . In most cases, the whole process of class loading is completed in this order . But there are exceptions , Parsing can also be performed after initialization , This is to support java Runtime binding for , And in the process of one stage, the latter stage may also be activated , Instead of waiting for the end of one phase before proceeding to the next .


- When a class is loaded by reference , Class will only be loaded once
Active reference to class ( Class initialization will happen )
- new An object of a class
- Calling static members of a class ( except final Constant ) And static methods
- Use java.lang.reflect Package's method makes a reflection call on the class
- When the virtual machine starts ,java Demo01, It must be initialized Demo01 class , To put it bluntly, start first main The class of the method
- When initializing a class , If its parent class is not initialized , Then initialize its parent class first
Class ( Class initialization will not occur )
- When accessing a static domain , Only classes with real names in this domain will be initialized
- Reference the static variables of the parent class through the child class , Does not cause subclass initialization
- Define a reference to a class through an array , Such initialization will not be triggered
- Reference constants do not trigger initialization of this class ( Constants are stored in the constant pool of the calling class at the compile stage )
- When accessing a static domain , Only classes with real names in this domain will be initialized
2. Let's talk about the parental delegation model
Why the parental delegation model
- Orderly
- Security ( Only the class loader and the class itself can determine a class (instanceof)): For example, write a package with the same name String class , Because class loaders are different, they can determine and jdk Is not a class

- Start class loader : The load is stored in <JAVA_HOME>\lib Catalog , Or be -Xbootclasspath Stored in the path specified by the , And it's Java Virtual machines can recognize ( Identify by file name , Such as rt.jar、tools.jar, The name doesn't match Even if the combined class libraries are placed in lib The directory will not be loaded ) The class library is loaded into the memory of the virtual machine .
- Extend the classloader : This class loader is in class sun.misc.Launcher$ExtClassLoader China and Israel Java In the form of code . It's responsible for loading <JAVA_HOME>\lib\ext Directory , Or be java.ext.dirs In the path specified by the system variable Some class libraries .
- Application class loader : This class loader consists of sun.misc.Launcher$AppClassLoader To achieve . Because the application class loader is ClassLoader Class getSystem-ClassLoader() Return value of method , So on some occasions Call it “ system class loader ”. It is responsible for loading the user classpath (ClassPath) All the class libraries on , Developers can also use this classloader directly in the code . If there is no customization in the application Use your own classloader , In general, this is the default classloader in the program .
3. Run time data area



- Virtual machine stack ( Thread stack ): Method call on and off the stack , Store the local variable table 【 There are also object reference addresses ( Point to the pile )】, The stack of operands ( Additive and subtractive … The values and results of such operations are temporarily stored ), Dynamic links ( Find the method area ( Meta space ) Address ), Methods the export ( Returns the location where this method was called )
- Program counter : Where to store program execution ( Address )( Multithreading Program execution may be suspended , You need to record where the execution has gone )
- Native Method Stack :native Method
- Method area ( Meta space ): Constant , Static variables , Class information
- Pile up :new Out object
Bytecode engine modify Program counter Value 
边栏推荐
- Permutation (greedy strategy)
- Swagger documentation details
- Jenkins Pipeline 语法
- mySql学习记录——二、mySql建表命令
- Jupyter notebook sets the default browser to open with an error syntaxerror: (Unicode error) 'UTF-8' codec can't decode byte 0xd4
- After going to the bathroom, I figured out the ES search server
- Permission modifiers and code blocks
- 目标识别、检测和 6D 姿态估算源码与方案(最先进的方法和数据集)
- 数据库常见面试题都给你准备好了
- MySQL installation
猜你喜欢
Database common interview questions are ready for you

2022 melting welding and thermal cutting test questions and answers

2022 low voltage electrician retraining question bank and online simulation examination
![[computer use] how to change a computer disk into a mobile disk?](/img/ff/843f4220fcaefc00980a6edc29aebf.jpg)
[computer use] how to change a computer disk into a mobile disk?

Machine learning notes - circular neural network memo list

Notes on data mining in Tsinghua University (1)
Common technical questions in functional test interview. Would you like to summarize them?

最少换乘次数

MySQL安装
软件测试工作经验分享,一定有你想知道的
随机推荐
抓取屏幕与毛玻璃效果
[character set 6] wide string and multi byte character conversion
机器学习笔记 - 循环神经网络备忘清单
SQL basic syntax II
MySQL安装
Multi table operation instance
测试计划应该怎么写?一个思路教会你
Use NVM to dynamically adjust the nodejs version to solve the problem that the project cannot be run and packaged because the node version is too high or too low
Basic knowledge of Linear Algebra -- concepts and relationships of common matrices
Swagger documentation details
APP测试面试题汇总,面试必考一定要看
目标识别、检测和 6D 姿态估算源码与方案(最先进的方法和数据集)
Selection of interview questions for software testing
Distributed transaction solution 1: TCC (compensation transaction)
重启Kubernetes Pod的几种方式
MySQL learning record - II. MySQL create table command
sql中的Exists用法
Complete knapsack problem 1
Grab screen and ground glass effect
[character set 7] what are the wide character codes and multi byte codes of Chinese characters