Angelika Langer - Training & Consulting

 
HOME | SEMINARS | TALKS | ARTICLES | BOOKS | LINKS | IOSTREAMS | GENERICS | ABOUT | NEWSLETTER | CONTACT | SITEMAP
Book Review - Java Language Specification 2nd Ed.

Books  
HOME 
SEMINARS 
TALKS 
ARTICLES 

BOOKS

  OVERVIEW
  REVIEWS

  BIBLIOGRAPHY    
    J2SE
    J2EE
    CORE C++
    STL
    TEMPLATES
    IOSTREAMS
    CONCURRENCY
    I18N
    PATTERNS
    OOA/OOD
    TESTING
    MANAGEMENT
 

LINKS 
IOSTREAMS 
GENERICS 
ABOUT 
NEWSLETTER 
CONTACT 
SITEMAP 
Book Review - Java Language Specification 2nd Ed.
   
  Book Review of the week  
 
 
  Java Language Specification, Second Edition
  By James Gosling et al.
  Reading,MA:Addison-Wesley
  ISBN 0201634511 
  544 pages 
 
  Price: $39.95 
(Reviewed 4/25/01) 
 
Java's Formal Spec Revealed 
This revised second edition drops the API and adds inner classes and strict floating-point arithmetic
H ere's a book for the serious Java developer. Java Language Specification, Second Edition , by James Gosling, Bill Joy, Guy Steele, and Gilad Bracha, provides a formal specification of the Java programming language. It is not a book that the average Java programmer needs to look at; it is a reference for gurus only. Do you aim to build a Java compiler, or are you interested in the details of the language semantics? Then you'll want this book. 

Once in a while normal Java textbooks fail to answer questions that the Java language specification can answer. Such questions include: 

  • What are the exact rules for conversions between reference types? (In other words, under which circumstances do I get a ClassCastException?)
  • What is the precise order of initialization of instance fields?
  • When are class fields initialized?
  • What is the order of finalization, if any?
  • When does an object become finalizable or unreachable, and what are the precise consequences?
  • Is access to variables guaranteed to be atomic?
  • What exactly does it mean if a variable is volatile? Does it guarantee atomicity for all types of objects? 
And so on. 

These aren't questions you are usually interested in. Only under extreme circumstances do these issues really matter. Textbooks typically do not delve deeply into every gory detail of the Java Language Specification, but focus instead on the most common cases. This way they avoid overwhelming the reader, which is probably a good idea. The JLS in contrast must go into every detail, because it aims to specify the language fully. 

Naturally, a formal specification is hard to read and understand, because it uses formal language and is full of technical terms and cross-references. In fact, the HTML version of the JLS, which you can download from Sun's Web site makes it much easier to use the cross references. 

Those of you who have been using the first edition of the language specification (JLS 1) might be interested in the differences between it and this second edition. The most obvious change is that the entire API specification has been removed. The API has grown enormously since 1996 and a formal specification of the JDK 1.3 packages does not fit into a single volume of any reasonable size. As a result, this book is the specification of the core language only. 

A couple of features have been added to the core of the language since the first edition's publication. Additions include nested types (often referred to as "inner classes") and strict floating point arithmetic. Naturally, JLS 2 contains specifications of these language features. 

There are other changes as well, some of which are kind of confusing. For instance, JLS 1 coined the technical terms "active and passive use" (a class is initialized at its "first active use"). In JLS 2 the term "active use" no longer exists. Instead, the description has been replaced by wording that expresses basically the same, but in different words. Sadly, Java Language Specification, Second Edition does not indicate what was changed or why. So we'll never know why there is no longer any "active use" in Java. 

Sometimes we wished we had the JLS 1 we are familiar with and the new JLS 2, side by side, so that we could match what we know from JLS 1 with what is specified in JLS 2. You may wish you could do that too. 

We didn't care much for this book's index because it didn't help us find what we were looking for. For instance, we tried to look up information about the creation of instances of inner classes. We vaguely remembered that the syntax involves the keyword "new." Did looking up "new" help? No. There isn't even an entry for "new"! What about "creation"? That took a while. Here's where we found it, under the Qs: "qualified class instance creation expression." If you know exactly what you're looking for, you can find it; otherwise, it's difficult. 

Criticisms aside, we feel that Java Language Specification, Second Edition is an indispensable part of every serious programmer's library of Java titles. Once and a while you'll appreciate having the definite reference available when you desperately need information about a certain detail of the language. This book might be your last resort. And what you don't find here, you'll probably find in the Java Virtual Machine Specification by Tim Lindholm and Frank Yellin (also published by Addison-Wesley). 

Angelika Langer develops and teaches classes on Java, C++, multithreading, and internationalization. She is an internationally recognized speaker and served on the ANSI/ISO C++ Committee from 1993 to 1998. Klaus Kreft is a software architect and senior consultant with 15+ years of experience in industrial software development. He currently works for Siemens Business Services in Germany. Langer and Kreft are authors of "Standard C++ IOStreams and Locales" (Addison-Wesley, 2000) and are columnists for the C/C++ Users Journal. 

 

 
© Copyright 1995-2003 by Angelika Langer.  All Rights Reserved.    URL: < http://www.AngelikaLanger.com/Articles/Reviews/JavaLanguageSpec/review.htm  last update: 28 Oct 2003