Contents | Prev | Next | Index


The JavaTM Virtual Machine Specification

Second Edition

Tim Lindholm
Frank Yellin




Preface

1 Introduction
1.1 A Bit of History
1.2 The Java Virtual Machine
1.3 Summary of Chapters
1.4 Notation

2 Java Programming Language Concepts
2.1 Unicode
2.2 Identifiers
2.3 Literals
2.4 Types and Values
2.4.1 Primitive Types and Values
2.4.2 Operators on Integral Values
2.4.3 Floating-Point Types, Value Sets, and Values
2.4.4 Operators on Floating-Point Values
2.4.5 Operators on boolean Values
2.4.6 Reference Types, Objects, and Reference Values
2.4.7 The Class Object
2.4.8 The Class String
2.4.9 Operators on Objects
2.5 Variables
2.5.1 Initial Values of Variables
2.5.2 Variables Have Types, Objects Have Classes
2.6 Conversions and Promotions
2.6.1 Identity Conversions
2.6.2 Widening Primitive Conversions
2.6.3 Narrowing Primitive Conversions
2.6.4 Widening Reference Conversions
2.6.5 Narrowing Reference Conversions
2.6.6 Value Set Conversion
2.6.7 Assignment Conversion
2.6.8 Method Invocation Conversion
2.6.9 Casting Conversion
2.6.10 Numeric Promotion
2.7 Names and Packages
2.7.1 Simple Names and Qualified Names
2.7.2 Packages
2.7.3 Members
2.7.4 Qualified Names and Access Control
2.7.5 Fully Qualified Names
2.8 Classes
2.8.1 Class Names
2.8.2 Class Modifiers
2.8.3 Superclasses and Subclasses
2.8.4 The Class Members
2.9 Fields
2.9.1 Field Modifiers
2.9.2 Initialization of Fields
2.10 Methods
2.10.1 Formal Parameters
2.10.2 Method Signature
2.10.3 Method Modifiers
2.11 Static Initializers
2.12 Constructors
2.12.1 Constructor Modifiers
2.13 Interfaces
2.13.1 Interface Modifiers
2.13.2 Superinterfaces
2.13.3 Interface Members
2.13.4 Overriding, Inheritance, and Overloading in Interfaces
2.14 Nested Classes and Interfaces
2.15 Arrays
2.15.1 Array Types
2.15.2 Array Variables
2.15.3 Array Creation
2.15.4 Array Access
2.16 Exceptions
2.16.1 The Causes of Exceptions
2.16.2 Handling an Exception
2.16.3 The Exception Hierarchy
2.16.4 The Classes Exception and RuntimeException
2.17 Execution
2.17.1 Virtual Machine Start-up
2.17.2 Loading
2.17.3 Linking: Verification, Preparation, and Resolution
2.17.4 Initialization
2.17.5 Detailed Initialization Procedure
2.17.6 Creation of New Class Instances
2.17.7 Finalization of Class Instances
2.17.8 Unloading of Classes and Interfaces
2.17.9 Virtual Machine Exit
2.18 FP-strict Expressions
2.19 Threads

3 The Structure of the Java Virtual Machine
3.1 The class File Format
3.2 Data Types
3.3 Primitive Types and Values
3.3.1 Integral Types and Values
3.3.2 Floating-Point Types, Value Sets, and Values
3.3.3 The returnAddress Type and Values
3.3.4 The boolean Type
3.4 Reference Types and Values
3.5 Runtime Data Areas
3.5.1 The pc Register
3.5.2 Java Virtual Machine Stacks
3.5.3 Heap
3.5.4 Method Area
3.5.5 Runtime Constant Pool
3.5.6 Native Method Stacks
3.6 Frames
3.6.1 Local Variables
3.6.2 Operand Stacks
3.6.3 Dynamic Linking
3.6.4 Normal Method Invocation Completion
3.6.5 Abrupt Method Invocation Completion
3.6.6 Additional Information
3.7 Representation of Objects
3.8 Floating-Point Arithmetic
3.8.1 Java Virtual Machine Floating-Point Arithmetic and IEEE 754
3.8.2 Floating-Point Modes
3.8.3 Value Set Conversion
3.9 Specially Named Initialization Methods
3.10 Exceptions
3.11 Instruction Set Summary
3.11.1 Types and the Java Virtual Machine
3.11.2 Load and Store Instructions
3.11.3 Arithmetic Instructions
3.11.4 Type Conversion Instructions
3.11.5 Object Creation and Manipulation
3.11.6 Operand Stack Management Instructions
3.11.7 Control Transfer Instructions
3.11.8 Method Invocation and Return Instructions
3.11.9 Throwing Exceptions
3.11.10 Implementing finally
3.11.11 Synchronization
3.12 Class Libraries
3.13 Public Design, Private Implementation

4 The class File Format
4.1 The ClassFile Structure
4.2 The Internal Form of Fully Qualified Class and Interface Names
4.3 Descriptors
4.3.1 Grammar Notation
4.3.2 Field Descriptors
4.3.3 Method Descriptors
4.4 The Constant Pool
4.4.1 The CONSTANT_Class_info Structure
4.4.2 The CONSTANT_Fieldref_info, CONSTANT_Methodref_info, and CONSTANT_InterfaceMethodref_info Structures
4.4.3 The CONSTANT_String_info Structure
4.4.4 The CONSTANT_Integer_info and CONSTANT_Float_info Structures
4.4.5 The CONSTANT_Long_info and CONSTANT_Double_info Structures
4.4.6 The CONSTANT_NameAndType_info Structure
4.4.7 The CONSTANT_Utf8_info Structure
4.5 Fields
4.6 Methods
4.7 Attributes
4.7.1 Defining and Naming New Attributes
4.7.2 The ConstantValue Attribute
4.7.3 The Code Attribute
4.7.4 The Exceptions Attribute
4.7.5 The InnerClasses Attribute
4.7.6 The Synthetic Attribute
4.7.7 The SourceFile Attribute
4.7.8 The LineNumberTable Attribute
4.7.9 The LocalVariableTable Attribute
4.7.10 The Deprecated Attribute
4.8 Constraints on Java Virtual Machine Code
4.8.1 Static Constraints
4.8.2 Structural Constraints
4.9 Verification of class Files
4.9.1 The Verification Process
4.9.2 The Bytecode Verifier
4.9.3 Values of Types long and double
4.9.4 Instance Initialization Methods and Newly Created Objects
4.9.5 Exception Handlers
4.9.6 Exceptions and finally
4.10 Limitations of the Java Virtual Machine

5 Loading, Linking, and Initializing
5.1 The Runtime Constant Pool
5.2 Virtual Machine Start-up
5.3 Creation and Loading
5.3.1 Loading Using the Bootstrap Class Loader
5.3.2 Loading Using a User-defined Class Loader
5.3.3 Creating Array Classes
5.3.4 Loading Constraints
5.3.5 Deriving a Class from a class File Representation
5.4 Linking
5.4.1 Verification
5.4.2 Preparation
5.4.3 Resolution
5.4.4 Access Control
5.5 Initialization
5.6 Binding Native Method Implementations

6 The Java Virtual Machine Instruction Set
6.1 Assumptions: The Meaning of "Must"
6.2 Reserved Opcodes
6.3 Virtual Machine Errors
6.4 Format of Instruction Descriptions

7 Compiling for the Java Virtual Machine
7.1 Format of Examples
7.2 Use of Constants, Local Variables, and Control Constructs
7.3 Arithmetic
7.4 Accessing the Runtime Constant Pool
7.5 More Control Examples
7.6 Receiving Arguments
7.7 Invoking Methods
7.8 Working with Class Instances
7.9 Arrays
7.10 Compiling Switches
7.11 Operations on the Operand Stack
7.12 Throwing and Handling Exceptions
7.13 Compiling finally
7.14 Synchronization
7.15 Compiling Nested Classes and Interfaces

8 Threads and Locks
8.1 Terminology and Framework
8.2 Execution Order and Consistency
8.3 Rules About Variables
8.4 Nonatomic Treatment of double and long Variables
8.5 Rules About Locks
8.6 Rules About the Interaction of Locks and Variables
8.7 Rules for volatile Variables
8.8 Prescient Store Operations
8.9 Discussion
8.10 Example: Possible Swap
8.11 Example: Out-of-Order Writes
8.12 Threads
8.13 Locks and Synchronization
8.14 Wait Sets and Notification

9 Opcode Mnemonics by Opcode

Appendix: Summary of Clarifications and Amendments

Index

Contents | Prev | Next | Index

The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to [email protected]