Electronic Review of Computer Books

[ ERCB Home | New | Feature | Brief | DDJ | Letters | Links ]

[an error occurred while processing this directive]

Vital Statistics

Title Java Virtual Machine
Author(s) Jon Meyer and Troy Downing
Publisher O'Reilly & Associates
Sebastopol, California
http://www.ora.com
Copyright 1997
ISBN 1-565-92194-1
Pages 462
Price $32.95


Under the Hood

By now, the mere mention of the word "Java" is enough to make most of us either swoon with delight or suffer hype-induced apoplexy. Aside from describing the latest version of the newest Java API/framework/IDE du jour, what else is left to say? Quite a lot, in fact, especially if you want to understand your tools from the inside out.

In Java Virtual Machine, which is based on Java 1.0.2, Jon Meyer and Troy Downing have written an interesting and useful book about the virtual machine that's at the core of every Java implementation. More so than most computer books, this book serves well as both tutorial and reference.

The tutorial material is in the first 11 chapters ("Overview," "Quick Tour," "Components of the Machine," "Classes," "Security," "Implementation Notes," "Data Operations," "Arithmetic," "Flow Control," "Exceptions," and "Threads"), while the reference material is in the last two chapters ("Class File Reference" and "Instruction Reference") and four appendices.

In the opening chapters, Meyer and Downing provide a good overview of Java. One teaching tool they use is Jasmin, their Java assembler, which is included on a diskette -- with complete Java source, no less. I'm normally skeptical about the value of author-invented languages, even assembly variations, but the numerous Jasmin examples they present are a terrific aid. And best of all, you can use Jasmin for real work or experimentally to find new and creative ways to crash a JVM.

The 196-page "Instruction Reference" chapter is the heart of the reference material, and is exactly what most of us want -- a detailed, instruction-by-instruction treatment of all opcodes required to implement a JVM, including example code, bytecodes, exceptions thrown, and cross references to related instructions.

For me, the most interesting parts of Java Virtual Machine discuss the code verifier and exceptions. The code verifier is the part of the JVM that attempts to ensure that a class file is robust and secure before running it, a very difficult task, and the source of at least one widely publicized Java bug. Support for exceptions turns out to be both more intricate and more elegant than I expected, thanks to the presence of finally blocks and the need to traverse the call chain to find a handler for the exception in question. The authors also show how simply JVMs handle virtual method invocation, and they provide a nice, brief discussion of garbage collection, something many programmers may not have considered in detail before working with Java.

I did have a few minor quibbles with Java Virtual Machine. The chapter on threads, far from being the meaty treatment I had hoped for, is a scant three pages in length. There are also several places where I suspect the authors' great familiarity with the material induced myopia. For example, they explain that the JVM will accept a 32-bit integer for some data types, and truncate the value as needed. One of the target types treated this way is boolean, which is defined as a single bit. This left me wondering if the high-order 31 bits really are ignored, or if JVMs use the common C convention of treating zero as False and any nonzero value as True. (In another place they say that only the integers 0 or 1 should be stored into a Boolean, which implies strict truncation really is used, and that Jasmin coders should be very careful about converting integers to Booleans.) In presenting the instructions that compare object references, Meyer and Downing say that equality means both references point to the same object, which is clear enough, but they skate over the issue of deep comparisons, something that should probably be mentioned at that point, however briefly.

As I wrote this review, CNN broadcast a tribute to Jacques Cousteau which quoted him as saying, "We must go and see for ourselves." The famous oceanographer spoke about a realm very different from the microcosm of Java's inner workings, but I believe the spirit still applies. After all, Meyer and Downing say that their book is for anyone "who is interested in Java technology and who wants to learn what goes on under the hood of the Java Virtual Machine." I agree; Java Virtual Machine is an excellent guide for programmers who are willing to delve beneath Java's surface and see for themselves.

-- Lou Grinzo


Copyright © 1997 Electronic Review of Computer Books
Created 11/26/97 / Last modified 11/26/97 / webmaster@ercb.com