Explanation of knowledge points of java jvm two types of storage areas

  • 2021-08-31 08:13:31
  • OfStack

We know that a lot of data is stored in jvm, so the place where the data is stored is called the storage area. Presumably, you don't know that there are two types of storage areas, constant buffer pools and method areas. I believe many people have not come into contact with this concept. This article sorts out the contents of jvm storage area in java. Let's take a look at the concepts and differences between these two storage areas.

1. Classification

JVM has two types of storage: constant buffer pools and method areas. Constant buffer pools are used to store class names, method names, and field names, as well as string constants. The method area is used to store the bytecode of the Java method. The JVM specification does not specify the specific implementation of these two storage areas. Therefore, the storage layout of an Java application must be determined at run time, depending on the implementation of the specific platform.

JVM is a platform-independent specification of the Java bytecode definition and is the foundation of Java platform independence. At present, there are still some limitations and shortcomings in JVM, which need to be improved by one step, but in any case, the idea of JVM is successful.

2. Comparative analysis

Think of Java source program as our C + + source program. The byte code generated by Java source program is equivalent to 80x86 machine code (binary program file) compiled by C + + source program. JVM virtual machine is equivalent to 80x86 computer system runs machine code in 80x86CPU and Java byte code in Java interpreter.

The Java interpreter is equivalent to the CPU running the Java bytecode, but this CPU is implemented not in hardware but in software. The Java interpreter is actually a platform-specific application. As long as the interpreter program under a specific platform is implemented, Java bytecode can run under the platform through the interpreter program, which is the foundation of Java cross-platform. At present, not all platforms have corresponding Java interpreter programs, which is why Java can't run on all platforms, but can only run on platforms that implement Java interpreter programs.

Expansion of knowledge points:

JVM is the abbreviation of Java Virtual Machine (Java virtual machine). JVM is a specification for computing devices. It is a fictional computer, which is realized by simulating various computer functions on an actual computer. The Java virtual machine consists of a bytecode instruction set, a set of registers, a stack, a garbage collection heap, and a storage method field. JVM shields the information related to the specific operating system platform, so that Java program can run on various platforms without modification only by generating the object code (bytecode) running on Java virtual machine. When JVM executes ByteCode, it actually finally interprets ByteCode as machine instruction execution on a specific platform.

1. JVM is the core and foundation of java, a virtual processor between java compiler and os platform. It is an abstract computer based on the lower operating system and hardware platform realized by software method, on which java bytecode program can be executed.

2. Architecture of JVM:

Class Loader (ClassLoader) (used to load. class files)

Execute the engine (execute bytecode, or execute local methods)

Run-time data area (method area, heap, java stack, PC register, local method stack)


Related articles: