This book describes the Java virtual machine, the abstract computer on which all Java programs run, and several core Java APIs that have an intimate relationship to the virtual machine. Through a combination of tutorial explanations, working examples, reference material, and applets that interactively illustrate the concepts presented in the text, this book provides an in-depth, technical survey of Java as a technology. The Java programming language seems poised to be the next popular language for mainstream commercial software development, the next step after C and C++. One of the fundamental reasons Java is a likely candidate for this role is that Java's architecture helps programmers deal with emerging hardware realities. Java has features that the shifting hardware environment is demanding, features that are made possible by the Java Virtual Machine. The evolution of programming languages has to a great extent been driven by changes in the hardware being programmed. As hardware has grown faster, cheaper, and more powerful, software has become larger and more complex. The migration from assembly languages to procedural languages, such as C, and to object oriented languages, such as C++, was largely driven by a need to manage ever greater complexity--complexity made possible by increasingly powerful hardware. Today the progression towards cheaper, faster, and more powerful hardware continues, as does the need for managing increasing software complexity. Building on C and C++, Java helps programmers deal with complexity by rendering impossible certain kinds of bugs that frequently plague C and C++ programmers. Java's inherent memory safety--garbage collection, lack of pointer arithmetic, run-time checks on the use of references--prevents most memory bugs from ever occurring in Java programs. Java's memory safety makes programmers more productive and helps them manage complexity. In addition, besides the ongoing increase in the capabilities of hardware, there is another fundamental shift taking place in the hardware environment--the network. As networks interconnect more and more computers and devices, new demands are being made on software. With the rise of the network, platform independence and security have become more important than they were in the past. The Java Virtual Machine is responsible for the memory safety, platform independence, and security features of the Java programming language. Although virtual machines have been around for a long time, prior to Java they hadn't quite entered the mainstream. But given today's emerging hardware realities, software developers needed a programming language with a virtual machine, and Sun hit the market window with Java. Thus, the Java virtual machine embodies the right software "stuff" for the coming years of computing. This book will help you get to know this virtual machine and some closely related Java APIs, and armed with this knowledge, you'll be better able to take maximum advantage of Java's unique architecture in your own endeavors. Who Should Read the Book
How to Use the Book
1. An introduction to Java's architecture (Chapters 1 through 4) 2. An in-depth, technical tutorial of Java internals (Chapters 5 through 20) 3. A class file and instruction set reference (Chapter 6, Appendices A through C) 4. Interactive illustrations and example source code (On the CD-ROM) 5. Java Virtual Machine Resources Page ( An Introduction to Java's Architecture
A Tutorial of Java Internals
A Class File and Instruction Set Reference
Interactive Illustrations and Example Source Code
The The copyright notice accompanying the .html, .gif, .java, and .class files for the Interactive Illustrationsenables you to post the web site on any network, including the internet, providing you adhere to a few simple rules. For example, you must post the web site in its entirety, you can't make any changes to it, and you can't charge people to look at it. The full text of the copyright notice is given later in this introduction. All the example source code shown in this book appears on the CD-ROM in both source and compiled (class files) form. If some example code in the text strikes you as interesting (or dubious), you can try it out for yourself. Most of the example code is illustrative and not likely to be of much practical use besides helping you to understand Java. Nevertheless, you are free to cut and paste from the example code, use it in your own programs, and distribute it in binary (such as Java class file) form. The full text of the copyright notice for the example source code is given later in this introduction. The Java Virtual Machine Resources Page
Copyright Notices
Copyright © 1997-1999 Bill Venners. All rights reserved. Source code file from the book "Inside the Java 2 Virtual Machine," by Bill Venners, published by McGraw-Hill, 1999, ISBN: 0-07-135093-4. This source file may not be copied, modified, or redistributed EXCEPT as allowed by the following statements: You may freely use this file for your own work, including modifications and distribution in compiled (class files, native executable, etc.) form only. You may not copy and distribute this file. You may not remove this copyright notice. You may not distribute modified versions of this source file. You may not use this file in printed media without the express permission of Bill Venners. BILL VENNERS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THIS SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE, OR NON-INFRINGEMENT. BILL VENNERS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY A LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. The HTML pages (including the applets) and Java source files for the Interactive Illustrations (stored in the
applets directory of the CD-ROM, consisting of ".html," ".gif," ".class," and ".java" files, are copyrighted © 1996, 1997 by Bill Venners, and all rights are reserved. This material may be copied and placed on any commercial or non-commercial web server on any network (including the internet) provided that the following guidelines are followed:
a. All the web pages and Java Applets (".html," ".gif," ".class," and ".java" files), including the source code, that are delivered in the b. All the web pages and Java Applets (".html," ".gif," ".class," and ".java" files) must be published "as is" and may not be altered in any way. c. All use and access to this web site must be free, and no fees can be charged to view these materials, unless express written permission is obtained from Bill Venners. d. The web pages and Java Applets may not be distributed on any media, other than a web server on a network, and may not accompany any book or publication. BILL VENNERS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE, OR NON-INFRINGEMENT. BILL VENNERS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY A LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. Java Versions
One change that occurred in JDK 1.0.2, a change of the semantics of the
Several of the Java APIs described in this book underwent significant changes between version 1.1, which was covered by the first edition of this book, and version 1.2, which is covered by this second edition. Perhaps the most significant API changes that affected this book are the many API changes that support the 1.2 security model. All the components of
the 1.2 security model -- the basic sandbox, code signing and authentication, policies and policy files, permissions, code sources, protection domains, and the stack inspection algorithms of the access controller -- are described in detail in Chapter 3, "Security." The Aside from several new APIs introduced to Java in version 1.2, this book incorporates the many clarifications and amendments to the original Java virtual machine specification that were printed in the second edition of the specification. For example, the second edition of the Java virtual machine specification documented a new set of loading constraints that ensure type safe linking in the presence of multiple class loaders. These loading constraints are described, and demonstrated by a code example, in Chapter 8, "The Linking Model." The revised floating point rules for Java virtual machines given in the second edition of the specification are explained in Chapter 14, "Floating Point Arithmetic." This second edition of this book also incorporates many corrections and clarifications to the specification of class file version numbers, method invocation, and the loading, linking, and initialization of types.
The bytecode examples shown throughout this book were generated by the The source code of the simulation applets (the interactive illustrations) adhere to Java version 1.0. As I discuss in Chapter 2, "Platform Independence," one of the realities of Java's platform independence promise is that you have to decide when a version of the Java Platform has been distributed widely enough to make it worthwhile to target that version. Although I had a 1.1 version of the Java virtual machine simulator applets working back in 1997, when it came time to deliver the CD-ROM material for the first edition of this book to the publisher, I opted to drop the code back down to 1.0. At the time, neither Netscape Communicator or Microsoft Internet Explorer fully supported 1.1. Since these applets are not example source, but are software products in their own right, I felt it didn't make sense to release them in 1.1. As a consequence, the applets will work in browsers that support either 1.0, 1.1, or 1.2, and hopefully many versions into the future. Request for Comments
|
Copyright © 1996-1999 Bill Venners. All Rights Reserved. |