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