Home > Store

Java¿ Virtual Machine Specification, The, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Java¿ Virtual Machine Specification, The, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1999
  • Edition: 2nd
  • Book
  • ISBN-10: 0-201-43294-3
  • ISBN-13: 978-0-201-43294-7

The nucleus of the Java(TM) 2 platform, the Java(TM) virtual machine is the technology that enables the Java 2 platform to host applications on any computer or operating system without rewriting or recompiling. The Java virtual machine is also responsible for the compactness of applications targeting the Java 2 platform, and is the basis for its security capabilities.

This book was written by those directly responsible for the design and implementation of the Java virtual machine, and is the complete and definitive specification for the technology. It is an essential reference for writers of compilers for the Java programming language and implementors of the Java virtual machine. This second edition specifies the newest version of the Java virtual machine and provides a fascinating view into the inner workings of the Java 2 platform.

In this book you will find comprehensive coverage of the class file format, the hardware, operating system, and implementation-independent binary format for compiled code. The authors fully describe the instruction set of the Java virtual machine. You will find an entire chapter of examples that demonstrate how to compile code written in the Java programming language into the instruction set of the Java virtual machine. In addition, the book presents a discussion on the vital topic of Java virtual machine threads and their interaction with memory.

All in all, this comprehensive, detailed, and methodical presentation provides the information necessary to implement your own fully compatible Java virtual machine.



0201432943B04062001

Sample Content

Table of Contents



Preface.


1. Introduction.

A Bit of History.

The Java Virtual Machine.

Summary of Chapters.

Notation.



2. Java Programming Language Concepts.

Unicode.

Identifiers.

Literals.

Types and Values.

Primitive Types and Values.

Operators on Integral Values.

Floating-Point Types, Value Sets, and Values.

Operators on Floating-Point Values.

Operators on boolean Values.

Reference Types, Objects, and Reference Values.

The Class Object.

The Class String.

Operators on Objects.

Variables.

Initial Values of Variables.

Variables Have Types, Objects Have Classes.

Conversions and Promotions.

Identity Conversions.

Widening Primitive Conversions.

Narrowing Primitive Conversions.

Widening Reference Conversions.

Narrowing Reference Conversions.

Value Set Conversion.

Assignment Conversion.

Method Invocation Conversion.

Casting Conversion.

Numeric Promotion.

Names and Packages.

Names.

Packages.

Members.

Package Members.

The Members of a Class Type.

The Members of an Interface Type.

The Members of an Array Type.

Qualified Names and Access Control.

Fully Qualified Names.

Classes.

Class Names.

Class Modifiers.

Superclasses and Subclasses.

The Class Members.

Fields.

Field Modifiers.

Initialization of Fields.

Methods.

Formal Parameters.

Method Signature.

Method Modifiers.

Static Initializers.

Constructors.

Constructor Modifiers.

Interfaces.

Interface Modifiers.

Superinterfaces.

Interface Members.

Interface (Constant) Fields.

Interface (Abstract) Methods.

Overriding, Inheritance, and Overloading in Interfaces.

Nested Classes and Interfaces.

Arrays.

Array Types.

Array Variables.

Array Creation.

Array Access.

Exceptions.

The Causes of Exceptions.

Handling an Exception.

The Exception Hierarchy.

The Classes Exception and RuntimeException.

Execution.

Virtual Machine Start-up.

Loading.

Linking: Verification, Preparation, and Resolution.

Initialization.

Detailed Initialization Procedure.

Creation of New Class Instances.

Finalization of Class Instances.

Unloading of Classes and Interfaces.

Virtual Machine Exit.

FP-strict Expressions.

Threads.



3. The Structure of the Java Virtual Machine.

The class File Format.

Data Types.

Primitive Types and Values.

Integral Types and Values.

Floating-Point Types, Value Sets, and Values.

The returnAddress Type and Values.

The boolean Type.

Reference Types and Values.

Runtime Data Areas.

The pc Register.

Java Virtual Machine Stacks.

Heap.

Method Area.

Runtime Constant Pool.

Native Method Stacks.

Frames.

Local Variables.

Operand Stacks.

Dynamic Linking.

Normal Method Invocation Completion.

Abrupt Method Invocation Completion.

Additional Information.

Representation of Objects.

Floating-Point Arithmetic.

Java Virtual Machine Floating-Point Arithmetic and IEEE 754.

Floating-Point Modes.

Value Set Conversion.

Specially Named Initialization Methods.

Exceptions.

Instruction Set Summary.

Types and the Java Virtual Machine.

Load and Store Instructions.

Arithmetic Instructions.

Type Conversion Instructions.

Object Creation and Manipulation.

Operand Stack Management Instructions.

Control Transfer Instructions.

Method Invocation and Return Instructions.

Throwing Exceptions.

Implementing finally.

Synchronization.

Class Libraries.

Public Design, Private Implementation.



4. The class File Format.

The ClassFile Structure.

The Internal Form of Fully Qualified Class and Interface Names.

Descriptors.

Grammar Notation.

Field Descriptors.

Method Descriptors.

The Constant Pool.

The CONSTANT_Class_info Structure.

The CONSTANT_Fieldref_info, CONSTANT_Methodref_info, and CONSTANT_InterfaceMethodref_info Structures.

The CONSTANT_String_info Structure.

The CONSTANT_Integer_info and CONSTANT_Float_info Structures.

The CONSTANT_Long_info and CONSTANT_Double_info Structures.

The CONSTANT_NameAndType_info Structure.

The CONSTANT_Utf8_info Structure.

Fields.

Methods.

Attributes.

Defining and Naming New Attributes.

The ConstantValue Attribute.

The Code Attribute.

The Exceptions Attribute.

The InnerClasses Attribute.

The Synthetic Attribute.

The SourceFile Attribute.

The LineNumberTable Attribute.

The LocalVariableTable Attribute.

The Deprecated Attribute.

Constraints on Java Virtual Machine Code.

Static Constraints.

Structural Constraints.

Verification of class Files.

The Verification Process.

The Bytecode Verifier.

Values of Types long and double.

Instance Initialization Methods and Newly Created Objects.

Exception Handlers.

Exceptions and finally.

Limitations of the Java Virtual Machine.



5. Loading, Linking, and Initializing.

The Runtime Constant Pool.

Virtual Machine Start-up.

Creation and Loading.

Loading Using the Bootstrap Class Loader.

Loading Using a User-defined Class Loader.

Creating Array Classes.

Loading Constraints.

Deriving a Class from a class File Representation.

Linking.

Verification.

Preparation.

Resolution.

Access Control.

Initialization.

Binding Native Method Implementations.



6. The Java Virtual Machine Instruction Set.

Assumptions: The Meaning of “Must.”

Reserved Opcodes.

Virtual Machine Errors.

Format of Instruction Descriptions.



7. Compiling for the Java Virtual Machine.

Format of Examples.

Use of Constants, Local Variables, and Control Constructs.

Arithmetic.

Accessing the Runtime 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.

Compiling Nested Classes and Interfaces.



8. Threads and Locks.

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.



9. Opcode Mnemonics by Opcode.


Appendix: Summary of Clarifications and Amendments.

Index. 0201432943T04062001

Preface

The Java(TM) virtual machine specification has been written to fully document the design of the Java virtual machine. It is essential for compiler writers who wish to target the 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 is implemented.

The Java virtual machine is an abstract machine. References to the Java virtual machine throughout this specification refer to this abstract machine rather than to Sun's or any other specific implementation. This book serves as documentation for a concrete implementation of the Java virtual machine only as a blueprint documents a house. An implementation of the Java virtual machine (known as a runtime interpreter) must embody this specification, but is constrained by it only where absolutely necessary.

The Java virtual machine specified here will support the Java programming language specified in The Java(TM) Language Specification (Addison-Wesley, 1996). It is compatible with the Java platform implemented by Sun's JDK(TM) releases 1.0.2 and 1.1 and the Java(R) 2 platform implemented by Sun's Java(R) 2 SDK, Standard Edition, v1.2 (formerly known as JDK release 1.2).

We intend that this specification should sufficiently document the Java virtual machine to make possible compatible clean-room implementations. If you are considering constructing your own Java virtual machine implementation, feel free to contact us 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. To learn the latest about the Java 2 platform, or to download the latest Java 2 SDK release, visit our World Wide Web site at http://java.sun.com. For updated information about the Java Series, including errata for The Java(TM) Virtual Machine Specification, and previews of forthcoming books, visit http://java.sun.com/Series

The virtual machine that evolved into the Java virtual machine was originally designed by James Gosling in 1992 to support the Oak programming language. The evolution into its present form occurred through the direct and indirect efforts of many people and spanned Sun's Green project, FirstPerson, Inc., the LiveOak project, the Java Products Group, JavaSoft, and today, Sun's Java Software. The authors are grateful to the many contributors and supporters.

This book began as internal project documentation. Kathy Walrath edited that early draft, helping to give the world its first look at the internals of the Java programming language. It was then converted to HTML by Mary Campione and was made available on our Web site before being expanded into book form.

The creation of The Java(TM) Virtual Machine Specification owes much to the support of the Java Products Group led by General Manager Ruth Hennigar, to the efforts of series editor Lisa Friendly, and to editor Mike Hendrickson and his group at Addison-Wesley. The many criticisms and suggestions received from reviewers of early online drafts, as well as drafts of the printed 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(TM) Language Specification, Addison-Wesley, 1996, 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.

Notes on the Second Edition

The second edition of The Java(TM) Virtual Machine Specification brings the specification of the Java virtual machine up to date with the Java(R) 2 platform, v1.2. It also includes many corrections and clarifications that update the presentation of the specification without changing the logical specification itself. We have attempted to correct typos and errata (hopefully without introducing new ones) and to add more detail to the specification where it was vague or ambiguous. In particular, we corrected a number of inconsistencies between the first edition of The Java(TM) Virtual Machine Specification and The Java(TM) Language Specification.

We thank the many readers who combed through the first edition of this book and brought problems to our attention. Several individuals and groups deserve special thanks for pointing out problems or contributing directly to the new material:

Carla Schroer and her teams of compatibility testers in Cupertino, California, and Novosibirsk, Russia (with special thanks to Leonid Arbouzov and Alexei Kaigorodov), painstakingly wrote compatibility tests for each testable assertion in the first edition. In the process they uncovered many places where the original specification was unclear or incomplete.
Jeroen Vermeulen, Janice Shepherd, Peter Bertelsen, Roly Perera, Joe Darcy, and Sandra Loosemore have all contributed comments and feedback that have improved this edition.
Marilyn Rash and Hilary Selby Polk of Addison Wesley Longman helped us to improve the readability and layout of this edition at the same time as we were incorporating all the technical changes.
Special thanks go to Gilad Bracha, who has brought a new level of rigor to the presentation and has been a major contributor to much of the new material, especially chapters 4 and 5 and the new "Appendix: Summary of Clarifications and Amendments." His dedication to "computational theology" and his commitment to resolving inconsistencies between The Java(TM) Virtual Machine Specification and The Java(TM) Language Specification have benefited this book tremendously.
Tim Lindholm
Frank Yellin
Java Software, Sun Microsystems, Inc.

References

--IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Std. 754-1985. Available from Global Engineering Documents, 15 Inverness Way East, Englewood, Colorado 80112-5704 USA, +1 800 854 7179.
--Hoare, C.A.R. Hints on Programming Language Design. Stanford University Computer Science Department Technical Report No CS-73-403, December 1973. Reprinted in Sigact/Sigplan Symposium on Principles of Programming Languages. Association for Computing Machinery, New York, October 1973.
--Unicode Consortium, The. The Unicode Standard: Worldwide Character Encoding, Version 1.0, Volume 1, ISBN 0-201-56788-1, and Volume 2, ISBN 0-201-60845-6. Updates and additions necessary to bring the Unicode Standard up to version 1.1 may be found at http://www.unicode.org --Unicode Consortium, The. The Unicode Standard, Version 2.0, ISBN 0-201-48345-9. Updates and additions necessary to bring the Unicode Standard up to version 2.1 may be found at http://www.unicode.org

0201432943P04062001

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020