Java is already very popular. More than 10,000 programmers around the world have developed in Java. Programs written in Java are also increasingly favored by their hardware environments. If you want to be a member of the Java world, then look at this series of articles may help you.
No matter which language needs to have its specific operational environment is platform, Java is equally an exception. You may ask, is the Java program not related to the hardware environment? Ok, I hope this article can answer this question.
Almost all languages need to be implemented by compilation or interpretation. However, Java has a different point, and it needs these two processes at the same time. In fact, it is precisely because this reason makes the language of Java has a platform-independent. When you write a Java program (of course you don't have to write the Java program). First, compile it into an intermediate code called bytecode through a translation program. Then, then translate it into a machine language to execute it as a machine language to execute the core of the machine. The JVM (Java virtual machine). The Java's compilation process is also different from other languages. For example, like a language like C , it is inseparable from the hardware platform information with the machine. The compiler is converted to the memory allocation mode of the program to ensure the operation of the program runs through the surfract table to convert the operands and opcodes of all instructions to memory. Java is a file that converts instructions into a * .class file, which does not contain hardware information. When you need to execute, you will find the address of the instruction after the memory layout is created after the Memory layout is created. This ensures that Java portability and safety are guaranteed. So why is the Java platform have such a good feature?
Usually a program running a platform is a hardware or software running environment. Currently popular is Windows 2000, Linux, Solaris, and MacOS. Java's platform is not the same, it consists of two parts: one is a Java Virtual Machine, Java virtual machine, and the other is the Java Application Programming Interface (Java API), the Java application design interface, the two software constitutes The basic environment of Java runs. The Java API is a big software collection. There are many controls needed in this collection to assist in development. Java API and JVM are integrated together on the machine hardware. That is, the Java platform separates a Java application from the hardware system to ensure the independence of the program. In order to better adapt to the development, Java designers provide us with three Java platforms: Java 2 Micro Edition (Java 2 Standard Edition (J2SE) and Java 2 Enterprise Edition (J2EE). Each version They all offer a wealth of development toolbox to adapt to different development needs.
Let us take a specific structure of the core JVM of the Java platform. In order to let the character code generated by the character code can be better explained and executed, a total of JVM is divided into the main 6: JVM interpreter, instruction system, register, stack, storage area, and debris recovery zone.
The JVM interpreter is the CPU of the processing field code of this virtual machine.
The JVM instruction system is similar to hardware computers. One instruction is divided into operation code and two parts of the operand. The opcode is 8-bit binary, and the operand can be determined as needed. The operation code is to illustrate the function of a command, so JVM can have up to 256 different operational instructions.
JVM has its own virtual registers so that you can quickly and JVM interpreters. For functionality, JVM sets commonly used 4 32-bit registers: PC (program counter), OPTOP, Frame (current execution environment pointer), VARS (pointing to the first part of the current execution environment) Pointer of the variable). The JVM stack is the location and control center of the data and information stored when the instruction is executed, which provides the information required for the JVM interpreter operation.
The JVM storage area is to store information such as bytecode after compiled bytecode.
JVM fragment recycling refers to reclaiming the specific examples of the Java classes that have been used from memory, which makes the developers eliminate the trouble and danger of their programming control memory. As JVM's continuous upgrading of its debris recovery is more reasonable. The classic algorithm has a reference count, copy, tag, clearance and tag - finishing. After the JVM1.4.1, a collection of collection techniques is generated, and it is simple to use the object to be divided into the time of the program, which is fragmented with this standard. About fragment recycling will be specially explained in future articles.