Java Reference
In-Depth Information
We'll discuss the second and third goals in Chapter 6 , when we talk about how the
Java environment deals with memory management.
The fourth goal, sometimes called “write once, run anywhere” (WORA), is the
property that Java class files can be moved from one execution platform to another,
and they will run unaltered provided a JVM is available.
This means that a Java program can be developed (and converted to class files) on
an Apple Mac machine running OS X, and then the class files can be moved to
Linux or Microsoft Windows (or other platforms) and the Java program will run
without any further work needed.
The Java environment has been very widely ported, including
to platforms that are very different from mainstream plat‐
forms like Linux, Mac, and Windows. In this topic, we use the
phrase “most implementations” to indicate those platforms
that the majority of developers are likely to encounter. Mac,
Windows, Linux, Solaris, BSD Unix, AIX, and the like are all
considered “mainstream platforms” and count within “most
In addition to these four primary goals, there is another aspect of the JVM's design
that is not always recognized or discussed—it makes use of runtime information to
Software research in the 1970s and 1980s revealed that the runtime behavior of pro‐
grams has a large amount of interesting and useful patterns that cannot be deduced
at compile time. The JVM was the first truly mainstream platform to make use of
this research.
It collects runtime information to make better decisions about how to execute code.
That means that the JVM can monitor and optimize a program running on it in a
manner not possible for platforms without this capability.
A key example is the runtime fact that not all parts of a Java program are equally
likely to be called during the lifetime of the program—some portions will be called
far, far more often than others. The Java platform takes advantage of this fact with a
technology called just-in-time (JIT) compilation.
In the HotSpot JVM (which was the JVM that Sun first shipped as part of Java 1.3,
and is still in use today), the JVM first identifies which parts of the program are
called most often—the “hot methods.” Then, the JVM compiles these hot methods
directly into machine code—bypassing the JVM interpreter.
The JVM uses the available runtime information to deliver higher performance than
was possible from purely interpreted execution. In fact, the optimizations that the
JVM uses now in many cases produce performance which surpasses compiled C
and C++ code.
Search WWH ::

Custom Search