当前位置:网站首页>Preliminary understanding of JVM
Preliminary understanding of JVM
2022-06-25 16:23:00 【Hurry to Friday】
jvm A preliminary understanding
JNI(java native interface) java Local interface :
Concept : JNI yes java Part of the language , Can pass JNI And other languages (C,C++) Interaction
JNI Provides JAVA A functional interface between a program and an operating system ,
Application scenarios :
1. When the program is performance sensitive , It is necessary to use a lower level language .
2. In the case that other languages have already implemented functions ,java It can be called directly .
3. When needed java Operating system dependent features that are not available
Use steps :
1. stay java Statement in the program native Method , Compile into a bytecode file (class)
2. use java Program , take class File generation header file ( command :java -jni xxx )
3. Implement... In other languages native Method , Generate dynamic library , for java Program usage
4. Release java Dynamic library
native keyword :
1.native The method of modification indicates that the method is not JAVA The realization of language , It is implemented in other languages , Out-of-service abstract To decorate , Because this method has a method body, but it just doesn't use java Language implementation .
java Program compiled into bytecode file ,jvm When executing bytecode files , The bytecode file will be interpreted into different machine instructions according to different operating systems , So as to achieve cross platform .
Program counter : It records the address of the virtual machine bytecode instruction being executed , Bytecode interpreter obtains the next bytecode instruction to be executed by changing the value of the program counter , Small memory space , Threads are private .
Virtual machine stack : Thread private , Life cycle is the same as thread , Describe the java Memory model for method execution : Each method creates a stack frame at execution time , Used to store local variable table , The stack of operands , Dynamic links , Method exit information . Each method is called from the end of the call , It corresponds to a stack frame from the virtual machine to the stack
Local variable table : All kinds of basic types known at compile time are stored (boolean、byte、char、short、int、float、long、double)、 Object reference (reference type ) and returnAddress type ( Points to the address of a bytecode instruction )
Native Method Stack : Different from virtual machine stack ,java The virtual machine stack is for java Method served , The local method stack is used for the virtual machine native Method served .
Pile up : Is part of thread sharing , Used to store object instances and arrays ,
Method area : It belongs to the shared memory area , Used to store class information loaded by virtual machine , Constant , Static variables , Just-in-time compiler compiled code and so on

Virtual machine stack , Program counter , The three memory areas of the local method stack are symbiotic with threads , The stack in the stack frame performs the operations of entering and exiting the stack as the method enters and exits . The heap and method areas are different , Is shared by threads , An interface may have multiple implementation classes , And each implementation class needs different memory , Only when the program is running can we know which implementation class to create ( And runtime type ), This part of the memory allocation and recycling are dynamic , By the garbage collector (GC) be responsible for .
Class loader :
The class loader is responsible for class Bytecode files are loaded into memory , And transform these contents into the method area , The class loader is only responsible for putting class Bytecode file loading , Not responsible for running , As for whether it can run , Determined by the execution engine .
Classification of class loaders :( Three + User customization )
1. Start class loader Bootstrap class loader(c++)
2. Extend the classloader Extension class loader(java)
3. Application class loader App class loader
User defined class loader ( Realization java.lang.ClassLoad Realization ) This is an abstract class
Parent delegate mechanism : When a class loader needs to load a class , I won't try to load this class myself . Instead, first delegate the parent class loader to load , Then the class loader that receives the delegate will also follow this rule , First, delegate your own parent class to try to load this class . Finally, it will be delegated to the startup class to load . When the required class is not found in the parent class loader , Subclasses try to load themselves .
The benefits of the parental delegation mechanism are : Sandbox security mechanism , It can ensure that the same class loads the same object .
边栏推荐
- What exactly is a handler
- Most commonly used SQL statements
- 不要小看了积分商城,它的作用可以很大!
- Built in function globals() locals()
- leetcode-8. 字符串转换整数 (atoi)
- Common APIs and exception mechanisms
- Advanced SQL statement 1 of Linux MySQL database
- When inputting text in the shutter textfield, if the page is refreshed, the cursor position will change.
- Analysis of the concept of metacosmic system
- 赫尔辛基交通安全改善项目部署Velodyne Lidar智能基础设施解决方案
猜你喜欢

面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
Mixed density network (MDN) for multiple regression explanation and code example

加密潮流:时尚向元宇宙的进阶

Prototype chain analysis

深入理解和把握数字经济的基本特征

Vscode有什么好用的插件?

Coredata data persistence

Don't underestimate the integral mall, its role can be great!

cmd。。。。。。

Interviewer: your resume says you are proficient in mysql, so you say cluster / Union / overlay index, table return, index push down
随机推荐
mysql整体架构和语句的执行流程
Servlet详解
User registration, information writing to file
What plug-ins are available for vscade?
[issue 24] one year experience of golang to develop futu
Once the code was encrypted by the company's computer, the compilation failed
Deep learning pytorch cifar10 dataset training "suggestions collection"
Multiple decorators decorate a function
[Third Party framework] retrofit2 (2) - add point configuration of network access framework
Hash table, generic
GO语言-什么是临界资源安全问题?
Stop "outsourcing" Ai models! The latest research finds that some "back doors" that undermine the security of machine learning models cannot be detected
error Parsing error: Unexpected reserved word ‘await‘.
ES6 deconstruction assignment rename
绕过技术聊'跨端'......
Beginner bug set
Principle analysis of ThreadLocal source code
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
Power representation in go language
Constructor Pattern