How Java Works

Source: Internet
Author: User

1java Virtual Machine

A Java Virtual machine is actually a software-simulated computer that interprets and executes a byte-code file of a word Java on any processor. Java 's bytecode is called the Java Virtual machine's machine code, which is saved in a file with a. class extension.

First Java source programs need to be compiled by the Java compiler into a bytecode file with a. class extension and then by Java in the Java Virtual machine The interpreter is responsible for interpreting the bytecode file into a specific machine code and executing it.


2 Automatic Memory recovery mechanism

During the execution of the program, the system allocates memory to the objects that are created, and when those objects are no longer referenced, the memory they occupy is discarded, and if the discarded memory is not reclaimed in time, the program will run inefficiently.

In the Java runtime Environment, there is always a system-level thread that specifically tracks the use of objects, periodically detects objects that are no longer in use, automatically reclaims the memory space they occupy, and reallocate the memory space to make them available to the program. This obsolete memory automatic recovery mechanism in Java allows you to write programs without having to consider the memory allocation of objects.


3 code security Check mechanism

Java is a network programming language, programs that run on the network must be secure. How do you ensure that Java programs downloaded from the Web are safe to carry without viruses? Java provides a code security check mechanism.

Java when an extension is named . Class The bytecode file is loaded to the virtual machine before it is executed, first Verify that the bytecode file conforms to the bytecode file specification and that there are some illegal operations in the code. The inspection work is performed by the bytecode Inspector or the security manager . After the test passes, the bytecode file is loaded into the Java Virtual machine, which is interpreted as the machine code and executed by the Java interpreter. The Java Virtual machine restricts the code and data of the program to a certain amount of memory space, and does not allow the program to be accessed beyond that range, guaranteeing the safe operation of the program.

How Java Works

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.