Java Virtual Machine

Source: Internet
Author: User

Java Virtual Machine (JVM) runs Jav.ProgramAn essential mechanism. Compiled Java program commands are not executed directly on the cpij of the hardware system, but by the JVM. JVM is the interface between compiled Java programs and hardware systems. programmers can regard JVM as a virtual processor. It not only interprets the compiled Java commands, but also performs security checks. It is a reliable guarantee that Java programs can be seamlessly transplanted across multiple platforms, and is also a security testing engine for Java programs.

The JVM Specification defines JVM: JVM is a hypothetical machine implemented on a real machine using software. JVM usedCodeStored in. Class file. Some JVM commands are similar to real CPU commands, including arithmetic operations, flow control, and array element access.

Java Virtual Machine specifications provide a hardware platform for compiling all Java code. Because the compilation is for hypothetical machines, this specification allows Java programs to be independent from the platform. It is applicable to each specific hardware platform to ensure that the Code Compiled for JVM runs. JVM can be implemented by software and hardware.

The specific implementation of JVM includes: Instruction Set (equivalent to the cpij Instruction Set), register group, class file format, stack, garbage collection heap, and memory zone.

The JVM code format is compressed bytecode, which is highly efficient. Programs represented by JVM bytecode must maintain the original type specification. The main types of Java check are completed by the bytecode validator during compilation. Any interpreter of Java must be able to execute any class files in the format of class files defined by JVM.

The Java virtual machine specification does not impose strict restrictions on the division of data regions and the optimization of bytecode during runtime. Their implementation varies depending on the platform. The implementation of JVM is called the Java runtime system. Java runtime must comply with the Java Virtual Machine specifications, so that class files generated by the Java compiler can be downloaded by all Java runtime systems. The Java program can be executed after the system application is embedded in the Java runtime. Currently, many operating systems and browsers are embedded in the Java Runtime Environment.

Java virtual machine performance at the beginning of Java, because it is not fully optimized and interpreted for execution, Java program running efficiency is low. At the same time, with a long history of development, the mature C + 10 language still plays a major role in the development field. People often compare the performance efficiency of C ++ with that of Java, this is of course biased.

The Java interpreter has been constantly optimized, and the execution speed of bytecode has been greatly improved. In addition, you can compile the Code through the JIT Compiler (Just In Time compiler) before the bytecode is executed to generate the local code for the specific platform. Its execution efficiency is 4-fold higher than that of interpretation ~ 8 times. Many manufacturers now provide jlt compilers. This technology is very mature. Because bytecode has nothing to do with the platform, the compiled Java still has the characteristics of cross-platform.

Hotspot technology is a new technology launched by Sun. It provides code runtime options to fundamentally solve the efficiency problem of Java programs. During program execution, hotspot analyzes each bytecode instruction and dynamically determines its execution mode based on the number of executions. For example, if a command needs to be executed multiple times, the code can be compiled as executable immediately. If a simple command is executed only once, and the efficiency of interpretation execution is higher, the method of interpretation execution is used. With this technology, the efficiency of javal can be basically solved.

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.