当前位置:网站首页>JVM class loading subsystem
JVM class loading subsystem
2022-07-24 16:38:00 【isTrueLoveColour】

- The classloader subsystem is responsible for loading from the file system or network Class file ,class The file must have a specific file ID at the beginning of the file
- The classloader subsystem is only responsible for class Loading of files , As for whether it can run , There are executive engine decisions
- The loaded class information is stored in a space called method go , In addition to class information , The method area also stores the constant pool information of the runtime , It may also include literal and numeric constants of strings ( This part of the constant information is class Memory mapping of constant pool in file )
class File loaded into jvm in , go by the name of DNA Metadata templates , Put it in the method area , Then you can call the constructor of this class , Create... In the heap class Example
Class loading process is divided into :
- load
- link
- initialization
load
loading load :
- Get the binary byte stream of a class through its permission qualified name
- Convert the static storage structure represented by the byte stream into the runtime data structure of the method area ( Classes will be placed in the method area ,jdk7 It used to be called permanent belt ,jdk8 It's called meta space )
- Generate a representation of this class in memory java.lang.Class object ,Class The instance of corresponds to the binary byte stream itself currently loaded into memory , As the access to all kinds of data of this class in method area
load .class How to file : Get... Locally 、 Through the network 、zip、 Runtime compute generation ( For example, dynamic agents )、 Other file generation ( for example jsp) etc.
link
It is divided into :
- verification : Make sure class The byte stream of the file contains information that meets the requirements of the current virtual machine , Ensure the correctness of the loaded class , It will not harm the security of the virtual machine itself ; It mainly includes four kinds of verification : File format validation , Metadata validation , Bytecode verification , Symbol reference validation
- Get ready :
- Allocate memory to the class and set the default initial value of the variable ,
- It doesn't include using final Embellished static, because final Assigned at compile time ( By final Modification is constant ), The preparation phase will show initialization
- There is no instance variable allocation initialization , Class variables are assigned in the method area , And instance variables are assigned to java In the pile
- analysis :
- The process of converting a symbolic reference in a constant pool to a direct reference
- Parsing operations are often accompanied by jvm Do not execute... Until initialization is complete
- Parsing actions are mainly for classes or interfaces 、 Field 、 Class method 、 Interface method, etc
initialization
- The initialization phase is the execution of class constructor methods < clinit > The process of , This method doesn't need to be defined , You only need static attributes or code blocks in the class ,javac The compiler will automatically collect the assignment actions of all variables of the class and combine them with the statements in the static code block
- Statements are executed in the order in which the source files appear
- If the class has a parent ,jvm Will guarantee the subclass < clinit > Before implementation , Executes the parent class < clinit >
- The virtual machine must guarantee a class of < clinit > Method is locked in the case of multithreading , Class only needs to be loaded once

Classloader classification :
Class loading is divided into :
- Boot class loader
- Custom loader (jvm It is stipulated that whoever inherits ClassLoader All classes are called custom class loaders , Therefore, the extension class loader and the system class loader are also the system definition class loader )
The boot class loader is not java Compiling ,java The core class libraries are loaded by the class loader ,
Other loaders are java Compiling
jvm The self-contained class loaders are : Boot class loader , Extend the classloader , system class loader
Boot class loader ( Start class loader )
- from c/c++ Language implementation , Nested in jvm Inside
- Used to load java The core library , For providing jvm The class you need
- No inheritance ClassLoader, No parent loader
- Responsible for loading extension class loader and application class loader ( The class loader is also the core class library , Classloader load classloader ), And specify their parent loader
- For safety reasons , The boot class loader only loads packages named :java,javax,sun Class with equal beginning
Extend the classloader :
- java To write , Derive from ( Indirect inheritance )ClassLoader
- The parent loader is the boot loader ( It's not inheritance , It's what loader loads )
- If the user created jar Put it in jre/lib/ext Under the table of contents , It will also be loaded by the extension class loader
System loader ( Application Loader )
- java Language writing , Derive from ClassLoader
- The parent class loader is the extension class loader ( It's not inheritance )
- Is the default class loader in the program , Generally speaking ,java Application classes are loaded by him
边栏推荐
- Long awaited full platform support - Open Source im project uniapp update of openim
- Servlet framework (servlet+jsp) + addition, deletion, modification and query + paging implemented by MySQL (function package student information entry, addition, deletion, modification and query of st
- Cache penetration, cache breakdown, cache avalanche differences and solutions [easy to understand]
- Causes and solutions of QT signal and slot connection failure
- js,for循环内callback异步转换成同步执行
- .NET 测试框架 xUnit,MSTest, Specflow 使用经验汇总
- Template method mode
- How to effectively avoid memory leakage when customizing the handler?
- Duplicate content in lookup table
- 1184. Distance between bus stops
猜你喜欢
随机推荐
Replace the image source of Debian full version with Alibaba cloud image source
[leetcode]38. counting - problem solving (execution time beat 91%, memory consumption beat 97%)
How to prevent XSS in PHP
Servlet framework (servlet+jsp) + addition, deletion, modification and query + paging implemented by MySQL (function package student information entry, addition, deletion, modification and query of st
详解 Apache Hudi Schema Evolution(模式演进)
Getting started with ARP
Enter a URL to this page to show it. What happened in this process?
多线程(基础)
Hping3 installation and use
1184. 公交站间的距离
[leetcode]75. color classification - problem solving (execution time beat 90%, memory consumption beat 78%)
双亲委派机制
会议OA项目进度(二)
如何在 PHP 中防止 XSS
Meeting OA project progress (I)
QT keyboard event (I) -- detect key input
Caikeng Alibaba cloud Kex_ exchange_ identification: read: Connection reset by peer
Telephone system rules
The 3D sensing market is accelerating. Who will be better, TOF or structured light?
Jupyter uses tips









