Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


Summary of Clarifications and Amendments


This appendix discusses the differences between the original version of The JavaTM Virtual Machine Specification and the present revision. Its purpose is twofold: to summarize what changes have been made and to explain why they were made.

Throughout this appendix, we refer to the original version of The JavaTM Virtual Machine Specification (that is, the first published version of this book) as the original specification or the original specification of the Java virtual machine. We refer to the current book as the revised specification. We denote the first edition of The JavaTM Language Specification as simply The JavaTM Language Specification.

The revised specification seeks to clarify points that gave rise to misunderstanding and to correct ambiguities, errors, and omissions in the original specification.

Except for the treatment of floating-point computation, the differences between the revised specification and its predecessor have no effect on valid programs written in the Java programming language. The revisions influence only how the virtual machine handles incorrect programs. In many of these instances, most implementations did not implement the original specification. The revised specification documents the intended behavior.

The most obvious changes are in the specification of floating-point types and operations; class file verification; initialization, loading, and linking; and the method invocation instructions. In addition, several other important corrections have been made.

The revised specification also fixes errors or clarifies issues that were brought to our attention by readers of the original specification.

While we have made every effort to correct as many problems as possible, we recognize that additional improvements would benefit this specification. In particular, we believe that the description of class file verification should be further refined, ideally to the point of constituting a formal specification. We anticipate that future revisions will address remaining weaknesses and correct any newly reported bugs, while retaining unchanged the semantics of the Java programming language.

The following sections discuss the changes to the original specification in greater detail and explain why the changes were necessary.


Floating-Point Types and Operations

The original specification required that all single- and double-precision floating- point calculations round their results to the IEEE 754 single- and double-precision formats, respectively. The revised specification permits additional floating-point calculations to be done using IEEE 754 extended precision formats.

As a result of this change, implementations on processors that more naturally and efficiently support extended precision formats and floating-point operations on extended precision formats can deliver better performance for floating-point calculations. Implementations on processors that naturally and efficiently implement IEEE 754 single- and double-precision operations as mandated by the original specification may continue to do so. The floating-point behavior of any Java virtual machine implementation that conforms to the original specification also conforms to the revised specification.


Changes to class File Verification

The most important clarification on the topic of class file verification is that every Java virtual machine implementation must in fact perform verification. This is stated unambiguously in the The JavaTM Language Specification. The original specification of the Java virtual machine contained several misleading sentences that led some readers to conclude that verification was optional.

The discussion of the class file format in Chapter 4 also corrects a number of small errors in the original specification. The most significant of these corrections are:

All of the preceding changes correct misstatements in the original specification that were obviously untrue. In addition, class file verification no longer bans attempts to invoke abstract methods; see a complete discussion of this issue later in this appendix.


Initialization

The JavaTM Language Specification and the original specification of the Java virtual machine contradict each other on the question of whether the element type of an array type must be initialized when an instance of the array type is created. The JavaTM Language Specification specifies that the element type should be initialized in this case, whereas the original specification of the Java virtual machine states that it should not. We have resolved this contradiction in favor of the original Java virtual machine specification. The JavaTM Language Specification is thus in error, and will be corrected in its next edition.

The evident confusion over the circumstances triggering initialization led us to reword the specification of when initialization occurs (§2.17.4). However, this reworded specification is equivalent to the original.

One of the original requirements was that a class would be initialized the first time one of its constructors is invoked. In the Java programming language, constructor invocation constitutes instance creation. Furthermore, since no instance method can be invoked if no instances exist, it is clear that the requirement that a class be initialized the first time one of its methods is invoked is relevant only for static methods. By similar reasoning, the requirement that a class be initialized if any of its fields is accessed applies only to static fields.

The original specification did not accurately describe the circumstances that would trigger initialization at the Java virtual machine level (see discussion later in this appendix). Section 5.5 now gives a simple and precise definition in terms of Java virtual machine instructions.


Loading and Linking

Chapter 5, "Loading, Linking, and Initializing," has been completely rewritten (and retitled). Chapter 5 of the original specification was erroneous in several important respects. The new chapter corrects these errors and tries to be both clearer and more precise. The organization of the revised chapter closely follows the structure of the corresponding sections in Chapter 12 of The JavaTM Language Specification.

The key changes include the following:


Changes to Method Invocation

The following changes have been made to the specification of the method invocation instructions. Many of these are direct consequences of the changes described in the previous section; others are designed merely to clarify the presentation.

          void bar(A a) {a.foo();} 

Nested Classes

Nested classes were introduced into the Java programming language after the original specification of the Java virtual machine and the first edition of The Java Language Specification were printed. The Innerclasses and Synthetic attributes, described in the revised specification in Section 4.7.5 and Section 4.7.6, respectively, were added in JDK release 1.1 in order to support nested classes.

Unfortunately, we have not been able to include a description of nested classes in the Java programming language overview given in Chapter 2. A complete description will be included in the next edition of the The JavaTM Language Specification. Until then, refer to the documentation on the World Wide Web at http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses.


Chapter 9 of Original Specification Deleted

Chapter 9, "An Optimization," of the original specification documented an optimization technique used in Sun's contemporary Java virtual machine implementation. The original specification was clear that this chapter and the technique it described were not part of the Java virtual machine specification. However, the chapter provided an example of the flexibility that the Java virtual machine specification intends to give implementors. This information about Sun's implementation was also considered possibly useful to writers of tools such as debuggers.

The chapter has been removed from the revised specification. The optimization technique it described is now well understood. More important, the technique exactly as described is not used by many of the Java virtual machine implementations, including some of Sun's, developed since the original specification was published. The value of the chapter to tool writers has diminished for the same reason. Thus, the chapter is now best seen as documentation for a specific Java virtual machine implementation, making it inappropriate for the Java virtual machine specification.


Other Issues


Contents | Prev | Next | Index

The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jvm@java.sun.com