The Java Language Specification, 3rd Edition
Read an excerpt:
Chapter 3: Lexical Structure
Excerpt provided courtesy of Addison-Wesley Professional. Copyright © Addison-Wesley. Written permission from the publisher is required for any use of this material.
|
Be the First to Write a Review and tell the world about this title!People who purchase this book frequently purchase: - The Java Programming Language, 4th Edition; Ken Arnold, et al, $42.95, 22% Off!
- Java Puzzlers: Traps, Pitfalls, and Corner Cases; Joshua Bloch, et al, $31.50, 21% Off!
- Java in a Nutshell, 5th Edition; David Flanagan, $28.50, 37% Off!
- The C++ Standard Library: A Tutorial and Reference; Nicolai M. Josuttis, $57.95, 23% Off!
Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:
Written by the inventors of the technology, The Java Language Specification,
Third Edition, is the definitive technical reference for the Java
programming language. If you want to know the precise meaning of the language's
constructs, this is the source for you.
The book provides complete, accurate, and detailed coverage of the Java
programming language. It provides full coverage of all new features added
since the previous edition, including generics, annotations, asserts, autoboxing,
enums, for-each loops, variable arity methods, and static import clauses.
Preface
This edition of the Java Programming Language Specification represents
the largest set of changes in the language's history. Generics, annotations,
asserts, autoboxing and unboxing, enum types, for-each loops, variable arity
methods and static imports have all been added to the language recently.
All but asserts are new to the 5.0 release of autumn 2004.
This third edition of The Java Language Specification reflects
these developments. It integrates all the changes made to the Java programming
language since the publication of the second edition in 2000.
The language has grown a great deal in these past four years. Unfortunately,
it is unrealistic to shrink a commercially successful programming language--only
to grow it more and more. The challenge of managing this growth under the
constraints of compatibility and the conflicting demands of a wide variety
of uses and users is non-trivial. I can only hope that we have met this
challenge successfully with this specification; time will tell.
Table of Contents
Preface.
Preface
to the Second Edition.
Preface
to the Third Edition.
1. Introduction.
Example Programs.
Notation.
Relationship to Predefined Classes and Interfaces.
References.
2. Grammars.
Context-Free Grammars.
The Lexical Grammar.
The Syntactic Grammar.
Grammar Notation.
3. Lexical
Structure.
Unicode.
Lexical Translations.
Unicode Escapes.
Line Terminators.
Input Elements and Tokens.
White Space.
Comments.
Identifiers.
Keywords.
Literals.
Separators.
Operators.
4. Types,
Values, and Variables.
The Kinds of Types and Values.
Primitive Types and Values.
Reference Types and Values.
Type Variables.
Parameterized Types.
Type Erasure.
Reifable Types.
Raw Types.
Intersection Types.
Subtyping.
Where Types Are Used.
Variables.
5. Conversions
and Promotions.
Kinds of Conversion.
Assignment Conversion.
Method Invocation Conversion.
String Conversion.
Casting Conversion.
Numeric Promotions.
6. Names.
Declarations.
Names and Identifiers.
Scope of a Declaration.
Members and Inheritance.
Determining the Meaning of a Name.
Access Control.
Fully Qualified Names and Canonical Names.
Naming Conventions.
7. Packages.
Package Members.
Host Support for Packages.
Compilation Units.
Package Declarations.
Import Declarations.
Top Level Type Declarations.
Unique Package Names.
8. Classes.
Class Declaration.
Class Members.
Field Declarations.
Method Declarations.
Member Type Declarations.
Instance Initializers.
Static Initializers.
Constructor Declarations.
Enums.
9. Interfaces.
Interface Declarations.
Interface Members.
Field (Constant) Declarations.
Abstract Method Declarations.
Member Type Declarations.
Annotation Types.
Annotations.
10. Arrays.
Array Types.
Array Variables.
Array Creation.
Array Access.
Arrays: A Simple Example.
Array Initializers.
Array Members.
Class Objects for Arrays.
An Array of Characters is Not a String.
Array Store Exception.
11. Exceptions.
The Causes of Exceptions.
Compile-Time Checking of Exceptions.
Handling of an Exception.
An Example of Exceptions.
The Exception Hierarchy.
12. Execution.
Virtual Machine Start-Up.
Loading of Classes and Interfaces.
Linking of Classes and Interfaces.
Initialization of Classes and Interfaces.
Creation of New Class Instances.
Finalization of Class Instances.
Unloading of Classes and Interfaces.
Program Exit.
13. Binary
Compatibility.
The Form of a Binary.
What Binary Compatibility Is and Is Not.
Evolution of Packages.
Evolution of Classes.
Evolution of Interfaces.
14. Blocks
and Statements.
Normal and Abrupt Completion of Statements.
Blocks.
Local Class Declarations.
Local Variable Declaration Statements.
Statements.
The Empty Statement.
Labeled Statements.
Expression Statements.
The if Statement.
The assert Statement.
The switch Statement.
The while Statement.
The do Statement.
The for Statement.
The break Statement.
The continue Statement.
The return Statement.
The throw Statement.
The synchronized Statement.
The try statement.
Unreachable Statements.
15. Expressions.
Evaluation, Denotation, and Result.
Variables as Values.
Type of an Expression.
FP-strict Expressions.
Expressions and Run-Time Checks.
Normal and Abrupt Completion of Evaluation.
Evaluation Order.
Primary Expressions.
Class Instance Creation Expressions.
Array Creation Expressions.
Field Access Expressions.
Method Invocation Expressions.
Array Access Expressions.
Postfix Expressions.
Unary Operators.
Cast Expressions.
Multiplicative Operators.
Additive Operators.
Shift Operators.
Relational Operators.
Equality Operators.
Bitwise and Logical Operators.
Conditional-And Operator &&.
Conditional-Or Operator ||.
Conditional Operator ? :.
Assignment Operators.
Expression.
Constant Expression.
16. Definite
Assignment.
Definite Assignment and Expressions.
Definite Assignment and Statements.
Definite Assignment and Parameters.
Definite Assignment and Array Initializers.
Definite Assignment and Enum Constants.
Definite Assignment and Anonymous Classes.
Definite Assignment and Member Types.
Definite Assignment and Static Initializers.
Definite Assignment, Constructors, and Instance Initializers.
17. Threads
and Locks.
Locks.
Notation in Examples.
Incorrectly Synchronized Programs Exhibit Surprising Behaviors.
Memory Model.
Final Field Semantics.
Word Tearing.
Non-atomic Treatment of double and long.
Wait Sets and Notification.
Sleep and Yield.
18. Syntax.
The Grammar of the Java Programming Language.
Index.
Credits.
Colophon.
About
the Authors
Guy L. Steele
Jr. is a Distinguished Engineer at Sun Microsystems, where he is responsible
for the specification of the Java programming language as well as research
in parallel algorithms. He is well known as the co-creator of the Scheme
programming language and for his reference books for the C programming language
(with Samuel Harbison) and for the Common Lisp programming language. Steele
received the ACM Grace Murray Hopper Award in 1988 and was named an ACM
Fellow in 1994.
He is the recipient of the 2005 Dr. Dobb's Excellence In Programming Award.
This prestigious award will be presented to Mr. Steele on March 15, 2005,
at CMP Media's Software Development Conference. Additionally, the April
2005 issue of Dr. Dobb's Journal includes an announcement on Mr. Steele's
achievements.
His far-reaching knowledge and expertise spans many languages, including
C, LISP, Fortran and the Scheme programming language, and has played an
integral role in many standards committees responsible for specifications
used today.
"The breadth of Mr. Steele's contributions and accomplishments is
legendary," said Jonathan Erickson, Dr. Dobb's Journal's editor-in-chief.
"It is a true pleasure to grant this award to Mr. Steele."
Dr. Dobb's Excellence in Programming Award is granted annually to individuals
who, in the spirit of innovation and cooperation, have made significant
contributions to the advancement of software development. Previous award
recipients include Linus Torvalds, Larry Wall, James Gosling, Ron Rivest,
Anders Hjelsberg, Adele Goldberg, Dan Ingalls, and P.J. Plauger, among others.
James Gosling is a Fellow and Vice President at Sun Microsystems, the creator
of the Java programming language, and one of the computer industry's most
noted programmers. He is the 1996 recipient of Software Development's "Programming
Excellence Award." He previously developed NeWS, Sun's network-extensible
window system, and was a principal in the Andrew project at Carnegie-Mellon
University, from which he holds a PhD in Computer Science.
Bill Joy is founder and Vice President of Research at Sun Microsystems,
where he has led the company's technical strategy, working on both hardware
and software architecture. He is well known as the creator of the Berkeley
version of the UNIX operating system, for which he received a lifetime achievement
award from the USENIX Association in 1993. He received the ACM Grace Murray
Hopper Award in 1986. Joy has had a central role in shaping the Java language.
Gilad Bracha is Computational Theologist at Sun Microsystems, and a researcher
in the area of object-oriented programming languages. Prior to joining Sun,
he worked on Strongtalk, the Animorphic Smalltalk System. He holds
a B.Sc. in Mathematics and Computer Science from Ben Gurion University in
Israel and a Ph.D. in Computer Science from the University of Utah.
|