1.1 Java Virtual Machine and Java

If you know Java, then you already have a pretty good understanding of some of the most important concepts in the Java virtual machine. That's because the JVM was intended, first and foremost, as a platform for running Java programs. You already have some idea of what a class is, what methods are, what an int is, and so on.

A Java program is a collection of class definitions written in the Java language. A Java compiler translates the Java programs into a format the JVM implementation understands. This translation process is called compilation.

This compiled form of the Java program is a collection of bytes, represented in a form called the class file format. These bytes may be kept in a file, in memory, on a web server, in a database, or anywhere else you can store a collection of bytes.

The class file contains instructions. When a JVM implementation reads and executes these instructions, the effect is what the original Java program called for. In programming language terms, we say that the class file has the same semantics as the original Java program.

The JVM is free to perform the actions specified by the instructions in any way it chooses, as long as it continues to obey the semantics of the instructions. A JVM implementation can choose from several implementation techniques. It can interpret the instructions or translate them into native machine code. The layout of memory is up to the JVM implementation. Different implementation techniques have their advantages and disadvantages, but no matter what, the results must conform to The Java Virtual Machine Specification, the official reference for JVM implementations.

Although the Java virtual machine was originally designed for the Java language, it is theoretically possible to design a translator from any programming language into the Java virtual machine's world. In practice, some languages are very difficult to implement efficiently, but some very interesting languages translate quite well. We'll discuss how some languages besides Java can be translated for the Java virtual machine in chapter 11.

Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net