JVM : Java Virtual Machine 架构
JVM Architecture Runtime Data Area/Memory Structure
Classloader
Class loader is a subsystem in JVM, which is primarily responasible for loading the java classes, there are 3 different class loaders :
- Bootstrap Classloader is the super class loader, which primharily loads the rt.jar, which contains the java.lang, java.net, java.io, java.sql package classes
- Extension Classloader is the sub of Bootstrap Classloader, it loads the library under JRE_HOME/lib/ext directory
- System/Application Classloader is the sub of ExtenstionClassloader, it loads the classes from the classpath, specified using the java -cp comrmand.
We can also create our own classloader by extending the Classsloader class Classloader is primarily performs three basic activities, in this order Loading → Linking - Initialization
JVM 内存区域
Runtime Data Areas(Heap | Method Area | JVM Stacks | PC Register | Native Stacks)
JVM 堆内存区域 Heap
Heap 数据结构
METHOD AREA / PERMANENT
Created at JVM startup and shared among all threads like Heap.
Per Thread Runtime Data Areas : PC Register & Stack Frame
- Local Variable Array
- Operand Stack
- Reference to Constant Pool
JVM Execute Engine
Interpreter
Interpreter is the one that reads the class files or bytecode and exectutes it one by one. The problem with the interpreter is that, when a method is called multiple times, it interprets those lines of bytecode again and again.
JIT compiler
JIT compiler helps in overcoming the problem of the interpreter. When repeated method calls occur, JIT compiler compiles the bytecode to native code. This native code will be used directly for repeated method calls . JIT compiler contains few components to achieve this feature.
Java native method interface
It is responsible for interacting with native libraries and makes it avvailable for the JVM execution engine.