Register your product to gain access to bonus material or receive a coupon.
Second Edition now available! |
The nucleus of the Java programming language, the Java Virtual Machine is the technology responsible for Java's cross-platform delivery, the small size of its compiled code, and its security capabilities.
Written by its designers and implementors, this book represents the complete and definitive specification for the Java Virtual Machine. It is an essential reference for compiler writers and Java Virtual Machine implementors. For all Java programmers, the book offers a unique and fascinating internal view of how Java really works.
In this book, you will find comprehensive coverage of the Java Virtual Machine class file format and instruction set. In addition, directions for compiling for the Java Virtual Machine with numerous practical examples clarify how the Java Virtual Machine operates in practice. The book also demonstrates the Java Virtual Machine's powerful verification techniques. In all, the book provides sufficient detail to enable you to implement your own fully-compatible Java Virtual Machine.
020163452XB04062001
Preface.
1. Introduction.
2. Java Concepts.
Unicode.
Identifiers.
Literals.
Types and Values.
Variables.
Conversions and Promotions.
Names and Packages.
Classes.
Fields.
Methods.
Static Initializers.
Constructors.
Interfaces.
Arrays.
Exceptions.
Execution.
Threads.
Data Types.
Primitive Types and Values.
Reference Types and Values.
Words.
Runtime Data Areas.
Frames.
Representation of Objects.
Special Initialization Methods.
Exceptions.
The class File Format.
Instruction Set Summary.
Public Design, Private Implementation.
ClassFile.
Internal Form of Fully Qualified Class Names.
Descriptors.
Constant Pool.
Fields.
Methods.
Attributes.
Constraints on Java Virtual Machine Code.
Verification of class Files.
Limitations of the Java Virtual Machine and class File Format.
Class and Interface Resolution.
Field and Method Resolution.
Interface Method Resolution.
String Resolution.
Resolution of Other Constant Pool Items.
Assumptions: The Meaning of "Must".
Reserved Opcodes.
Virtual Machine Errors.
The Java Virtual Machine Instruction Set.
Format of Examples.
Use of Constants, Local Variables, and Control Constructs.
Arithmetic.
Accessing the Constant Pool.
More Control Examples.
Receiving Arguments.
Invoking Methods.
Working with Class Instances.
Arrays.
Compiling Switches.
Operations on the Operand Stack.
Throwing and Handling Exceptions.
Compiling finally.
Synchronization.
Terminology and Framework.
Execution Order and Consistency.
Rules About Variables.
Nonatomic Treatment of Double and Long Variables.
Rules About Locks.
Rules About the Interaction of Locks and Variables.
Rules for Volatile Variables.
Prescient Store Operations.
Discussion.
Example: Possible Swap.
Example: Out-of-Order Writes.
Threads.
Locks and Synchronization.
Wait Sets and Notification.
Dynamic Linking via Rewriting.
The _quick Pseudo-instructions.
About the Java SeriesThe Java Series books provide definitive reference documentation for Java programmers and end users. They are written by members of the Java team and published under the auspices of JavaSoft, a Sun Microsystems business. The World Wide Web allows Java documentation to be made available over the Internet, either by downloading or as hypertext. Nevertheless, the worldwide interest in Java technology led us to write and publish these books to supplement all of the documentation at our Web site.
To learn the latest about the Java Platform and Environment, or to download the latest Java release, visit our World Wide Web site at http://java.sun.com. For updated information about The Java Series, including sample code, errata, and previews of forthcoming books, visit http://java.sun.com/Series.
We would like to thank the Corporate and Professional Publishing Group at Addison-Wesley for their partnership in putting together the Series. Our editor Mike Hendrickson and his team have done a superb job of navigating us through the world of publishing. Within Sun, the support of James Gosling, Ruth Hennigar, Jon Kannegaard, and Bill Joy ensured that this series would have the resources it needed to be successful. In addition to the tremendous effort by individual authors, many members of the JavaSoft team have contributed behind the scenes to bring the highest level of quality and engineering to the books in the Series. A personal note of thanks to my children Christopher and James for putting a positive spin on the many trips to my office during the development of the Series.
Lisa Friendly
Series Editor
PrefaceThis book has been written as a complete specification for the Java Virtual Machine. It is essential for compiler writers who wish to target a Java Virtual Machine and for programmers who want to implement a compatible Java Virtual Machine. It is also a definitive source for anyone who wants to know exactly how the Java programming language works.
The Java Virtual Machine is an abstract design. This book serves as documentation for a concrete implementation of Java (including Sun's) only as a blueprint documents a house. Any implementation of Java must embody this specification of the Java Virtual Machine, but is constrained by it only where absolutely necessary.
This book describes Version 1.0.2 of the Java Virtual Machine, which is compatible with Version 1.0.2 of the Java programming language, as specified in The Java Language Specification (Addison-Wesley, 1996). Future versions of the Java Virtual Machine will be backward compatible with this specification.
We intend that this specification should sufficiently document the Java Virtual Machine to make possible compatible clean-room implementations. Sun provides tests which verify the proper operation of implementations of the Java Virtual Machine. If you are considering constructing your own implementation, please contact us at the email address below to obtain assistance to ensure the 100% compatibility of your implementation.
Send comments on this specification or questions about implementing the Java Virtual Machine to our electronic mail address: jvm@java.sun.com.
The original Java Virtual Machine was designed by James Gosling in 1992. It evolved to its present form through the direct and indirect efforts of many people, spanning Sun's Green Project, FirstPerson, Inc., the LiveOak project, Java Products Group, and JavaSoft. The authors are grateful to the many contributors.
This book began as internal project documentation. Kathy Walrath edited this early work, helping to give the world its first look at the internals of Java. It was then converted to HTML by Mary Campione and was made available on our Web site before being expanded into book form.
The present document owes much to the support of the group led by General Manager Ruth Hennigar and to the efforts of series editor Lisa Friendly and Mike Hendrickson of Addison-Wesley. The many criticisms and suggestions received from reviewers of early online drafts, as well as drafts of the book, improved its quality immensely. We owe special thanks to Richard Tuck for his careful review of the manuscript and to the authors of The Java Language Specification for allowing us to quote extensively from that book. Particular thanks to Bill Joy whose comments, reviews, and guidance have contributed greatly to the completeness and accuracy of this book.
Tim Lindholm
Frank Yellin
JavaSoft
June, 1996
020163452XP04062001