Secret behind Java: Virtual Machine Components 02

Source: Internet
Author: User
To learn more about Java virtual machines, you must first take a look at the components of the virtual machines. What are the components of each part? What are their functions and relationships. We all know that the Java Virtual Machine simulates a hardware computer. It can be imagined that the Java Virtual Machine is a hardware computer with memory, CPU, input/output, and nic. The following figure shows the composition of a virtual machine:

As soon as Java was launched, it was launched on a cross-platform basis. The principle is to compile the target file into a Java bytecode file and interpret and execute it through a virtual machine. It will eventually be compiled into the corresponding commands of the target system. For example, Sun virtual machines are available on Windows, Linux, and Mac OS. However, when every platform interprets its bytecode files, the bytecode files are the same, the commands on the underlying machine are different. It can be seen that Java cross-platform is ridiculous, but this idea is great. This is also the source of many complaints about low Java language efficiency.

JVM mainly includes two subsystems and two components. The two subsystems are the class loader subsystem and the execution engine subsystem. The two components are respectively the runtime data area and the Native Interface.

Class Loader sub-system: this can be imagined as an I/O device in a hardware computer, according to the given fully qualified name Class Name (such as Java. lang. object) to load the content of the class file to the Method Area (method area) in the runtime data area ). Java programmers can inherit the java. Lang. classloader class to write their own classloader.

Execution engine subsystem: this can be imagined as the CPU of a computer and executed commands in the. Class file compiled by Java. JVM has many implementations, such as Sun's JDK, IBM's JDK, open-source opensdk, and Android's Dalvik virtual machine. The core of any JVM implementation JDK is the execution engine subsystem. The performance of different JDK depends on the performance of their respective execution engines.

Native Interface Component: this can be imagined as a computer Nic. Android may know JNI. The local interface component allows Java to call some implementations of underlying C and C ++, interacts with some local class libraries. When the native method is called, it enters a completely new world that is no longer limited by the Java Virtual Machine. Therefore, it is easy to see native heap outofmemory that cannot be controlled by JVM.

Runtime data area component: It can be imagined as the memory in the computer, which is also known as the JVM memory. It is usually divided into five parts:
1. Method Area: The loaded Java class information, that is, the bytecode information, is stored here;
2. java stack space: used to store the local variables, operands, intermediate results, and execution context information of each running Java thread (256 kb before jdk5.0 and 1 MB later );
3. native method stack local method Stack: Save the local method to enter the region address;
4. Heap heap space: used to store Java instance objects;
5. program counter register program counter: each Java thread has its own PC register, which is also created when the thread is started. The content of the PC register always points to the address of the next instruction to be executed. The address here can be a local pointer or offset corresponding to the start instruction of the method in the method area;

In the preceding five parts, only heap and method area are shared and used by all threads. The other three are thread-specific, and each thread has its own part.

Source www.boobooke.com/bbs-> J2EE area-> Blue Mountains work-secrets behind Java (Summary)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.