The JVM consists of two subsystems and two components

1. Introduction to JVM

JVM is the abbreviation of Java Virtual Machine (Java Virtual Machine). JVM is a specification for computing equipment. It is a fictitious computer that is realized by simulating various computer functions on an actual computer.

Due to the existence of the JVM, Java does not need to be recompiled when running on different platforms. The portability of Java is based on the JVM (different versions of JVM are installed on different systems). As long as any platform is equipped with a JVM specific to the platform, the bytecode file (.class) can run on the platform. This is "compile once, run anywhere".

2. The composition and function of JVM

  1. The two subsystems are Class loader (class loader) and Execution engine (execution engine);
  2. The two components are Runtime data area (runtime data area) and Native Interface (native library interface).

The role of each component:

  1. Class loader (class loader): According to the given fully qualified class name (eg: java.lang.Object ) to load the class file into the method area in the runtime data area.
  2. Execution engine (execution engine): The execution engine is also called an interpreter, which is responsible for interpreting commands and handing them over to the operating system for execution.
  3. Native Interface (local interface): It interacts with native libraries and is an interface for other programming languages ​​to interact.
  4. Runtime data area (runtime data area): This is often referred to as JVM memory. All written programs are loaded here before they start running.

Process:
Firstly, the Java code is converted into bytecode by the compiler, and then the class loader (ClassLoader) loads the bytecode into the memory, and puts it in the method area of ​​the runtime data area (Runtime data area), and The bytecode file is only a set of instruction set specifications for the JVM, and cannot be directly handed over to the underlying operating system for execution. Therefore, a specific command parser execution engine (Execution Engine) is required to translate the bytecode into the underlying system instructions, and then hand it over to the underlying system. It is executed by the CPU, and in this process, it is necessary to call the native library interface (Native Interface) of other languages ​​to realize the functions of the entire program.

Guess you like

Origin blog.csdn.net/ChineseSoftware/article/details/125232956