Errata for
The Java Class Libraries: Second Edition, Volume 1
Supplement for the JavaTM 2 Platform, Standard Edition, v1.2

by

Patrick Chan, Rosanna Lee, and Douglas Kramer


If you find an error in the book, please check this list first to see if it is already known. If not, please mail us the relevant information, including page numbers. All errata will be fixed in the next possible printing.

The errata is categorized by the printing number of the book. You can tell which printing you have by looking at the bottom of the copyright page. The last line of that page indicates the printing number.


Errata for All Printings

PhantomReference, Page 658

SoftReference, Page 817

WeakReference, Page 980

On these three pages, there is a typographical error in the example in the Usage section. Replace
Reference r = rq.remove();
with
Reference r = q.remove();

Errata for First to Third Printings

java.net Package Description

Page 31
In the last sentence of the paragraph in the Sockets subsection of Changes for Version 1.2, SocketOptions is erroneously referred to as a "class." The sentence should read:
The SocketOptions interface has been added for socket implementation developers to use for setting and getting socket options.

AbstractCollection.add()

Page 58
In the second paragraph in the DESCRIPTION section, change IllegalArgumentException to NullPointerException.

Arrays

Page 124
The compact() method shown in the Usage section should return an Object[] instead of an Object.

AttributedCharacterIterator.Attribute.equals()

Page 145
In the EXAMPLE section, replace attr1.equals(attr) with attr1.equals(attr2) (in the last statement of the example), and delete the extraneous closing brace immediately after the last statement.

Class.forName()

Page 254
In the DESCRIPTION section, there are two errors and one clarification. First, the first form of forName() always performs class initialization before returning the class when the class is first loaded. Therefore in the third paragraph, the last sentense should read
If the class has not been loaded yet, then this form causes the class to be loaded using the class loader of the calling method and initialized.
Second, replace the third and fourth sentences in the fourth paragraph.
init should be set to true when an instance of the class being requested is being created or if that class's methods are to be invoked. init should be set to false if the class is being loaded simply to check its existence or to get its superclasses.
with
init should be set to false to load a class without initialization. The initialization causes performance problems for some applications, such as class introspection tools, that simply want to load a class and use reflection without creating an instance or otherwise accessing the class.
Third, add the following new fifth paragraph.
Because the second form of this method accepts an explicit loader parameter, you can use it instead of loader's public loadClass() method. This overload of forName() is often a better choice because loadClass() does not handle array class names.

In the 1.2 CHANGES section, add the following sentences to the end of the paragraph.

In Version 1.2, the first form of forName() always performs class initialization before returning the class when the class is first loaded. In Version 1.1, whether initialization is performed was unspecified.

Collection

Page 296
In the last sentence of the first paragraph in the Description section, Collection is erroneously referred to as a "class." The text should read:
The Collection interface represents a generic collection of objects.

Collections.reverse()

Page 315
In the EXAMPLE section, insert a closing brace immediately before the closing parenthesis in the first line, so that it reads:
List l = Arrays.asList(new String[] {"dog", "pig", "cat"});

Comparable

Page 327
In the class example, the statement in the first for loop should read:
set.add(new MyPoint((int)(rnd.nextInt(100)), (int)(rnd.nextInt(100))));

Comparator

Page 331
In the class example, the statement in the first for loop should read:
set.add(new MyPoint((int)(rnd.nextInt(100)), (int)(rnd.nextInt(100))));

HashMap

Page 423
In the Capacity and Load Factor section, the formula given in the section is wrong. It should read as follows instead.
size() > load_factor*capacity

Manifest

Page 550, 555
The method hashCode() is missing from the MEMBER SUMMARY table and from the Member Descriptions.

Manifest.clone()

Page 552-553
In the EXAMPLE section, replace the three occurrences of
Attributes.put(string1, string2)
with
Attributes.put(new Attributes.Name(string1), string2)
Also, delete the three lines
// Clearing the original also does not affect the clone.
man.clear();
printAttributes(manCopy.getMainAttributes());// Manifest-Version: 1.0
and add the following three to the end of the method:
// Clearing the original also does not affect the clone.
man.clear();
printAttributes(manCopy.getMainAttributes());// Manifest-Version: 2.0

Manifest.getEntries()

Page 549, 554
In the code example, replace,
attr.put("Sealed", "true");
with
attr.put(new Attributes.Name("Sealed"), "true");

System

Page 862
Add the following disclaimer to the system properties listed in Table 28.
Note that some items on this list are implementation-specific and subject to change without notice.

System.setProperty

Page 870
The description for the val parameter should be: "A non-null string representing the property's value."

TreeMap.TreeMap()

Page 914
The wrong example was included in the EXAMPLE section. The prose should read: This example creates a TreeMap that sorts keys in reverse lexicographical order. The code should read:
TreeMap map = new TreeMap(Collections.reverseOrder());
map.put("pig", null);
map.put("cow", null);
map.put("dog", null);
map.put("cat", null);

System.out.println( map );   // {pig=null, dog=null, cow=null cat=null}

ZipEntry

Page 983
In the first sentence of the first paragraph in the Changes for Version 1.2 section, ZipEntry is erroneously referred to as a "method.". The text should read:
The ZipEntry class implements Cloneable and exports a public clone() method.

This page was updated: 1-Oct-2001