Hardcore Java by Robert Simmons The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated February 27, 2008. UNCONFIRMED errors and comments from readers: [?] 2.2.2.1 (Safari Version); In both code samples: this.name.length and name.length should be this.name.length() and name.length(). [15] Labels section; The method matrixMeth2 purports to show how "break RESTART;" can transfer control back to the beginning of the statement labeled "RESTART", but this is completely wrong: it transfers control to the end of the labeled statement, so the matrix processing is certainly not restarted. This section also refers to lines as being labeled, but it is statements that are labeled, not lines. And it says that a label must appear first on a line and not at the end, but this is wrong: a label can appear anywhere in a line; what matters is that the label be followed (on this line or a later one) by a colon and then (perhaps on yet another line) by a statement. [31] Example 1-8; Class should begin as follows (taken from the online examples) otherwise the printed output does not make sense. public class StaticOrderDemo { static { Class cl = Values.class; System.out.println("Class " + cl.getName() + " Loaded"); } (72) 2nd Paragraph (code sample); The comment for the development mode constant hcj_bankdata has mistakenly been copied for all of the other constants declared. {81} 1st new paragraph (after first code snippet); It seems that the sentence "The compiler will allocate a new object only when the StringBuffer exceeds its capacity." should instead read "The virtual machine will allocate a new object only when the StringBuffer exceeds its capacity." (81) last paragraph; for the "Buffering Bad Perfomance" example "Referring to the javadoc documentation on the stringbuffer class" should be "Referring to the javadoc documentation on the string class" [85] First code snippet (example of good interface-based technique); The original example of a good interface-based technique reads: public class SomeClass { HashSet someSet = new HashSet(); protected Set someMethod() { return this.someSet; } } This is NOT a good interface-based technique. As a matter of fact this is identical to the example of the bad interface-based technique later on page 85. It should be: Set someSet = new HashSet(); (87) last sentence of next-to-last paragraph; Suggest changing sentence wording from: For this reason, you should use only a SortedMap if you must have a fixed iteration order. To: For this reason, you should use a SortedMap only if you must have a fixed iteration order. [133] second paragraph, second sentence; "Since the inner class is public, you can create an instance of PixelPoint outside of the enclosing class". Should be "Since the inner class and the constructor are public, you can create an instance of PixelPoint outside of the enclosing class". See page 132 [167] second paragrph in the box, last sentence; "For example, if your subclass was SomeExceptionType, referencing SomeExceptionType.LOGIC_BAD_PARAMETER would cause a compiler error". This is wrong: static member can also be access by the subclass. [170] 1st paragraph after example 7-9; Line 3 of the located paragraph, it is told that "There is absolutely no need to validate the country here or anywhere else in the code!". A client of Adress2.setCountry(Country2) could passes it "null". Which can result in a hard-to-find-bugqs explained in many places in the book. So the setters shall validate the parameter with a constraint (cf. chapter 8, "Reusable Data Constraints"). {176} 2nd paragraph, line 1; The Sun's official documentation (1.4.2) of java.io.Serializable specifies that a serializable class may declare the method member "writeReplace" instead of "writeResolve". {263} last paragraph, last sentence; "Similarily, if you dropped the X-to-D reference, D and X would both be garbage collected". X is strongly reachable through C-F-X and will not be garbage collected [269] 3rd paragraph (Reference Queues); For java.lang.ref.ReferenceQueue Book states: poll() This checks the reference queue to see whether there are any reference objects in the queue. If it finds one, it returns the first reference in the queue. This reference is left on the queue. API documentation (http://java.sun.com/j2se/1.4.2/docs/api/) states: poll() Polls this queue to see if a reference object is available. If one is available without further delay then it is removed from the queue and returned. Otherwise this method immediately returns null. i.e. book is wrong in saying that reference is left on the queue. Book states: remove() This removes the first reference on the queue and returns it to the caller. If there are no references on the queue, it returns null. API documentation (http://java.sun.com/j2se/1.4.2/docs/api/) states: remove() Removes the next reference object in this queue, blocking until one becomes available. i.e. book is wrong in saying that method returns null if there are no references on the queue, as the method will block until a reference becomes available. [272] last code snippet; This last code snippet of the last paragraph tells you to use the WeakHashSet. There is no WeakHashSet. You have to use the WeakHashMap. This will break other parts of the code when you switch because a map uses the put method instead of the add method. Also the code snippet in the first paragraph of the same page uses a set and again you will have the same issue. you will have to change the add methods to put methods. This will also cause an error That states the method put(Object, Object) is not applicable for the arguments (String) [274] second paragraph and second code sample; The string that was referenced by y is still strongly reachable through p. it will therefore not be garbage collected, no matter how long you wait. The while loop will therefore never terminate. (291) first note; should appear at the end of section on enums, not on static imports. {295} first and second listing (syntax); The Syntax of Generics in both example Listings: " public Type getValue(){ return this.value(); } " should be " public Type getValue(){ return this.value; } " (298) note on autoboxing; Autoboxing is only for assignments, not for declarations. This is why Sun didn't implement declaring generic types with primitives. And yes, using a List with ints automatically boxes the ints, so there is nothing lost.