Friday, October 3, 2008

JVM - Java Virtual Machine

  • The Java Virtual Machine (JVM) is an abstract computer that runs compiled Java programs.


  • The JVM executes Java bytecodes, which can be thought of as the machine language of the JVM.

The Java virtual machine (JVM) specification consists of the following:

- The bytecode syntax, including opcode and operand sizes, values, and types, and their alignment and endian-ness

- The values of any identifiers (for example, type identifiers) in bytecodes or in supporting structures

- The layout of the supporting structures that appear in compiled Java code (for example, the constant pool)

- The Java .class file format

Each of these is covered in this chapter.
Despite this degree of specificity, there are still several elements of the design that remain (purposely) abstract, including the following:

- The layout and management of the run-time data areas

- The particular garbage-collection algorithms, strategies, and constraints used

- The compiler, development environment, and run-time extensions (apart from the need to generate and read valid Java bytecodes)

- Any optimizations performed, once valid bytecodes are received
These places are where the creativity of a virtual machine implementor has full rein.

The Fundamental Parts

The Java virtual machine can be divided into five fundamental pieces:


- A bytecode instruction set
- A set of registers
- A stack
- A garbage-collected heap
- An area for storing methods

Some of these might be implemented by using an interpreter, a native binary code compiler, or even a hardware chip—but all these logical, abstract components of the virtual machine must be supplied in some form in every Java system.

The virtual machine, and its supporting code, is often referred to as the run-time environment.



No comments: