View
240
Download
0
Category
Preview:
Citation preview
8/19/2019 Bug Fixes 8th Ed.
1/12
Welcome to the Core Java Bug List
8th Edition Volume 1 (Java SE 6)8th Edition Volume 2 (Java SE 6)7th Edition Volume 1 (Java SE 5.0)7th Edition Volume 2 (Java SE 5.0)6th Edition Volume 1 (Java SE 1.4)There was no 6th Edition Volume 25th Edition Volume 1 (Java SE 1.3)5th Edition Volume 2 (Java SE 1.3/1.4)4th Edition Volume 1 (Java SE 1.2)4th Edition Volume 2 (Java SE 1.2)3rd Edition (JDK 1.1)2nd Edition (JDK 1.02)1st Edition (JDK 1.0)
How to Tell which Printing You Have
On the bottom of the copyright page (facing the first page of the table of contents), look for a line such asFirst printing, April 2008
In the errata below, we indicate the printing in which the error has been fixed inside square brackets such as [4].
For example, suppose you have the fourth printing. Then you can ignore all reports that are prefixed with [2], [3] or [4]. But you wouldwant to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.
8th Edition Volume 1 (Java SE 6)
Page 11 [2]
In Table 1-1, change the year for Version 1.4 from 2004 to 2002
Page 16
Remove “As a middle ground, we show you how to use a text editor that can call the Java compiler andr un Java programs.”
Page 21
Change “(after expansion of j2sdkversion-doc.zip)” to “(after expansion of jdk- version-doc.zip)”
Page 22
Change “devlopment” to “development“
Page 28
Remove “(To compile and run this program inside a text editor or an integrated developmentenvironment, do the same as before. For example, for Emacs, choose JDE -> Compile, then chooseJDE -> Run App.)
Page 33
Change the tip to: You can also run applets from inside your integrated development environment. In Eclipse, use the Run -> Runas -> Java Applet menu option.
Page 39
Remove “This is shown in Listing 3–1.”
Page 51 Figure 3-1 [2]
Add an arrow from float to double
Page 57
Change "Fortunately, ... " until the end of the section to:
You can move backwards with the following statements:
i‐‐;if (Character.isSurrogate(sentence.charAt(i))) i‐‐;int cp = sentence.codePointAt(i);
Page 69 [2]
Change “the decimal separator is a period, not a comma” to “the group separator is a period not a comma”
Page 70 [2]
Change "If the file does not exist, you can simply" to "If the file does not exist, it is created. You can simply"
Page 90 [2]
Change "This statement sets up an array that can hold 100 integers." to "This statement creates an array of 100 integers. Whenyou create an array of numbers, all elements are initialized with 0. (Arrays of boolean are initialized with false, arrays of objectswith null values.)"
Page 91
http://www.horstmann.com/corejava/bugs2.html#FirstEditionhttp://www.horstmann.com/corejava/bugs2.html#SecondEditionhttp://www.horstmann.com/corejava/bugs4.html#CJ4V2http://www.horstmann.com/corejava/bugs5.html#CJ5V1http://www.horstmann.com/corejava/bugs7.html#CJ7V1http://www.horstmann.com/corejava/bugs4.html#CJ4V2http://www.horstmann.com/corejava/bugs7.html#CJ7V1http://www.horstmann.com/corejava/bugs5.html#CJ5V1http://www.horstmann.com/corejava/bugs2.html#SecondEditionhttp://www.horstmann.com/corejava/bugs7.html#CJ7V2http://www.horstmann.com/corejava/bugs2.html#ThirdEditionhttp://www.horstmann.com/corejava/bugs4.html#CJ4V1http://www.horstmann.com/corejava/bugs5.html#CJ6V1http://www.horstmann.com/corejava/bugs5.html#CJ5V2http://www.horstmann.com/corejava/bugs2.html#FirstEdition
8/19/2019 Bug Fixes 8th Ed.
2/12
Change “Chapter 2 of Volume II” to “Chapter 13”
Page 91, 93, 100 [2]
Change "entries" to "elements" (5x)
Page 93 [2]
Change “the copyTo method” to “the copyOf method”
Page 93 Figure 3-14 [2]
Change 12 to 13
Page 98
Change static int binarySearch(type[] a, int start, int end type v) to static int binarySearch(type[] a,int start, int end, type v) (i.e. add the comma)
Change static type copyOf(type[] a, int length) to static type[] copyOf(type[] a, int length)
Change static type copyOf(type[] a, int start, int end) to static type[] copyOfRange(type[] a, int start,int end)
Page 100
Change “array balance” to “array balances” and balance[0].length to balances[0].length
Page 103 [2]
Change "entry" to "element" (2x)
Page 107 [2]
Change “Thinking about classes as cookie cutters.” to “Think about classes as cookie cutters.”
Page 113 Figure 4-4 [2]
Change the second birthday to deadline
Page 113 [2]Change "Variables are not automatically initialized to null." to "Local variables are not automatically initialized to null."
Page 161 [2]
Change MyProg.java to MyProg (2x)
Page 180
Change manager[0] to managers[0] and manager[i] to managers[i]
Pages 181, 185, 218 [2]
Change “runtimeruntime” to “runtime”
Page 192 [2]
Change “see Volume II for more on threads” to “see Chapter 14 for more on threads”
Page 197 [2]
Change “Chapter 2 of Volume II.” to “Chapter 13.”
Page 211
Change list.add(new Integer(3)); to list.add(Integer.valueOf(3));Page 215
Change
Size s = (Size) Enum.valueOf(Size.class, "SMALL");
to
Size s = Enum.valueOf(Size.class, "SMALL");
Page 221
Change “private and protected members” to “private, package, and protected members”
Page 227
Add a semicolon after if (!r.endsWith("[")) r += ","
Page 252 [2]
Add a semicolon after
cloned.hireDay = (Date) hireDay.clone()
Page 253
Change
return super.clone();
to
return (Employee) super.clone();
8/19/2019 Bug Fixes 8th Ed.
3/12
Page 253
Change
int[] cloned = (int[]) luckyNumbers.clone();
to
int[] cloned = luckyNumbers.clone();
Page 258 [2]
Change javax.awt.Toolkit to java.awt.Toolkit
Page 277
Change Proxy.newInstance to Proxy.newProxyInstance
Page 286 SimpleFrameTest.java [2]
Replace lines 11-13 with
EventQueue.invokeLater(new Runnable() { public void run() { SimpleFrame frame = new SimpleFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } });
Then add a line at the top of the file
import java.awt.*;
Page 290 [2]
Change
setLoationByPlatform(true);
to
setLocationByPlatform(true);
Page 298 NotHelloWorld.java [2]Change lines 36 and 37 to
NotHelloWorldComponent comp = new NotHelloWorldComponent(); add(comp);
In line 45, change “panel” to “component”
Change line 47 to
class NotHelloWorldComponent extends JComponent
Page 299
Change “overrides this method” to “override this method”
Page 328Change
class ButtonPanel extends JFrame
to
class ButtonFrame extends JFrame
Page 344 [2]
Change “you nee to know” to “you need to know”
Page 352
Add a } below repaint(); that lines up with the { below the if.
Page 365 [2]
8/19/2019 Bug Fixes 8th Ed.
4/12
8/19/2019 Bug Fixes 8th Ed.
5/12
String filename = (String) files.get(0);
Page 618 [2]
Change “wrong,and” to “wrong, and“
Page 618
Change
public static T getMiddle(T[] a)
to
public static T getMiddle(T... a)
and
String[] names = { "John", "Q.", "Public" };String middle = ArrayAlg.getMiddle(names);
to
String middle = ArrayAlg.getMiddle("John", "Q.", "Public");
and
String middle = ArrayAlg.getMiddle(names);
to
String middle = ArrayAlg.getMiddle("John", "Q.", "Public");
Page 618
Change “The error message is: “found: java.lang.Number&java.lang.Comparable>, required: double”. You will learn later in this chapter how to decipher the “found” type declaration.” to“The error message complains, in cryptic terms that vary from one compiler version to another, that there are two ways of interpreting this code, both equally valid.”
Page 623
Change ”Erasure of method” to “Erasure of methods”
Page 624
Change “In the erased type” to “In the DateInterval class”. Change // defined in Pair to // overrides the methoddefined in Pair to call the first method
Page 626
Change // same as a instanceof Pair and // T is ignored to // ERROR. Change “really only tests” to “could only test”.Change “compiler warning whenever you use instanceof or cast expressions that involve generic types.” to “compiler error (withinstanceof) or warning (with casts) when you try to inquire whether an object belongs to a generic type.
Page 628
Change “an array Object[2]” to “an array Comparable[2]”
Page 629
Change minmax(T[] a) to minmax(T... a) (2x). Change “is assigned to the String[] variable” to “is cast to Comparable[] as themethod returns.”
Page 634
Change “a generic objects” to ”a generic object”Page 634
Change ”The compiler doesn’t know the exact type of the setFirst method but can call it with any object of type Manager,Employee, or Object, but not a subtype such as Executive. However,” to ”The compiler doesn’t know the exact type of thesetFirst method and therefore can't call it with an object of type Employee or Object, but only with type Manager or a subtypesuch as Executive. Moreover,”
Page 636 [2]
Change “you can call the setObject method” to “you can call the setFirst method”
Page 636 [2]
Change “tests whether a pair contains a given object.” to “tests whether a pair contains a null reference.”
Page 636
Change “turning contains into” to “turning hasNulls into”
Page 646
8/19/2019 Bug Fixes 8th Ed.
6/12
In the API note for WildCardType, flip the headers • Type[] getLowerBounds() and • Type[] getUpperBounds(), but not thetext below. (I.e. getUpperBounds gets the extends bounds.)
Page 637 [2]
Change
PairAlg.swapHelper(result);
to
PairAlg.swap(result);
Page 656/657
In the last line of page 656, change : c to : this. In the second line of page 657, remove the = inreturn = true;
Page 660 [2]
Change “and and then removes” to “and then removes”
Page 671 SetTest.java [2]
Change line 26 to
for (int i = 1; i
8/19/2019 Bug Fixes 8th Ed.
7/12
* @param aComponent the component in which the ball bounces
Page 727
Remove
public static final int STEPS = 1000;public static final int DELAY = 3;
from BounceThread.java
Page 730 [2]
Change Thread().currentThread().interrupt() to Thread.currentThread().interrupt()
Page 735
Change getDefaultExceptionHandler to getDefaultUncaughtExceptionHandler
Page 751 [2]
Change “you should you should” to “you should”
Page 755
Change ”call await accounts[from] >= balance” to ”call await accounts[from] >= amount”
Page 758
Change “at least one of the accounts must have more than $1,000” to ”at least one of the accounts must have at least $1,000”
Page 760 [2]
Change “Transfer $997 to from Account 1” to “Transfer $997 from Account 1”
Page 762
Change ”TransferThread” to ”TransferRunnable”
Page 770Change "unbounded bounded" to "unbounded"
Page 780
Change “connection pool” to “thread pool”
Page 790
Remove line 82 and change 1 to 0 in line 91
Page 793
Change “given maximum number” to “given number”
Page 803
Change "GUI of in" to "GUI in"
Page 810
After “a null reference”, add: (Note that null is actually a literal, not a keyword.)
8th Edition Volume 2 (Java SE 6)
Page 7 [3]
In figure 1-3, the arrow from CharBuffer to Reader should instead point to the Readable interface.
Page 10
Change “A buffered input stream reads characters” to “A buffered input stream reads bytes”
Page 11
Change “A buffered output stream collects characters” to “A buffered output stream collects bytes”
Page 22
Change “the static wrap method of the ByteBuffer array” to “the static wrap method of the ByteBuffer class”
Page 54
Change out.write(value); to out.write(original);
Page 64Change “or null if none exist.” to “or null if this File was not representing a directory.”
Page 74
Change boolean exclusive to boolean shared (2x). Change “The exclusive flag is true” to “The shared flag is false” and “It isfalse” to “It is true”.
Page 80
Change "11;59am" to "11:59am
Page 80
Change the listing caption from RegexTest to RegExTest to match the file name
Page 83 [3]
Change HrefMatch.java Line 33
"
8/19/2019 Bug Fixes 8th Ed.
8/12
to
"
8/19/2019 Bug Fixes 8th Ed.
9/12
Remove the line
JLabel label = new JLabel();
Page 393
Change
else setBorder(null);}return this;
to
else setBorder(null); return this;}
Page 407
In Figure 6-17, the arrow between DefaultTreeModel and TreeModel should be dotted
Page 437
Remove the paragraph starting “This example concludes our discussion on trees.”
Page 425
Change
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
to
Component comp = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus
and
setFont(font);return this;
to
comp.setFont(font);return comp;
Page 487
Change “Volume I, Chapter 12” to “Chapter 1”
Page 529 [3]
Change
skewedAngle = Math.toDegrees(Math.atan2(x * width, y * height));
to
skewedAngle = Math.toDegrees(Math.atan2(‐y * height, x * width));
Page 636/7
Remove ”The parameter of the getContents call...retrieve as text”.
Page 658
Change “Next, override the getTransferable method” to “Next, override the createTransferable method”
Page 667
Change “Inthat case, you cannot use local clipboards. Fortunately, you can place” to “You can accomplish this task by placing”
Page 704
Change “The FileNameBean has an indexed extensions property and a constrained filename property” to “The FileNameBean hasa filename property and an indexed extensions property”
Page 708
Change
IndexedPropertyChangeEvent(Object sourceBean, String propertyName, int index,
8/19/2019 Bug Fixes 8th Ed.
10/12
Object oldValue, Object newValue)
to
IndexedPropertyChangeEvent(Object sourceBean, String propertyName,Object oldValue, Object newValue, int index)
Page 710
Change
PropertyDescriptor descriptor = new PropertyDescriptor("fileName", ImageViewerBean.class);
to
PropertyDescriptor descriptor = new PropertyDescriptor("fileName", FilePickerBean.class);
Page 710
Change
class ImageViewerBeanBeanInfo extends SimpleBeanInfo{ public PropertyDescriptor[] getPropertyDescriptors() { return propertyDescriptors; }
private PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[] { new PropertyDescriptor("fileName", ImageViewerBean.class); };}
to
public class ImageViewerBeanBeanInfo extends SimpleBeanInfo{ private PropertyDescriptor[] propertyDescriptors;
public ImageViewerBeanBeanInfo() {
try { propertyDescriptors = new PropertyDescriptor[]
{ new PropertyDescriptor("fileName", FilePickerBean.class); }
} catch (IntrospectionException e) { e.printStackTrace(); } }
public PropertyDescriptor[] getPropertyDescriptors()
{ return propertyDescriptors; }}
Page 734
Change “listers” to “listeners”
Page 777
In the CAUTION note, change “in the current directory” to “in the home directory”
Page 792
Change “On Windows, change Unix to NT in both AuthTest.policy and jaas.config” to “On Windows, change UnixPrincpal toNTUserPrincipal in AuthTest.policy and UnixLoginModule to NTLoginModule in jaas.config”
Page 840
Change JSEE to JSSE
8/19/2019 Bug Fixes 8th Ed.
11/12
Page 857
Change “When the local garbage collector finds that there are further local uses” to “When the local garbage collector finds thatthere are no further local uses”
Page 874/875
Change
Then use a SecretKeyFactory, like this:
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("AES");byte[] keyData = . . .; // 16 bytes for AESSecretKeySpec keySpec = new SecretKeySpec(keyData, "AES");
Key key = keyFactory.generateSecret(keySpec);
to
Then construct a SecretKeySpec (which implements the SecretKey interface) like this:
byte[] keyData = . . .; // 16 bytes for AESSecretKey key = new SecretKeySpec(keyData, "AES");
Page 882
Remove “In the next chapter, we turn to ...programming language on the same machine.”
Page 886
Change
engine.eval("f.text = ’Ok’");
to
engine.eval("b.text = ’Ok’");
Page 915
Change
@BugReport(reportedBy={"Harry", "Carl"}))
to
@BugReport(reportedBy={"Harry", "Carl"})})
Page 919
Change
@Inherited @Persistent { }
to
@Inherited @interface Persistent { }
Page 937
Change “just as you would invoke the Java compiler” to “just as you would start a Java program”
Page 944, 956
Change “Volume I, Chapter 12” to “Chapter 1”
Page 948
The code in Listing 12-10 is jumbled. Lines 22-26 are out of order. The correct sequence of lines is: 25, 26, 22, 23, 24, 27.
Page 950
Change “Here, class is a value that represents a Java object of type Class, fieldID is a value” to “Here, fieldID is a value”.
Change “There are two ways to obtain the class object.” to “To obtain the fieldID, you must first get a value representing theclass, with you can do in one of two ways.”
Thanks to Yasir Bajwa, Chad Bamford, Chris Bolliger, Fred Brasch, Jonathan Camilleri, Francisco Gómez Carrasco, Lynn Robert Carter,Mark Chamberlin, Arnab Dutta Chowdhury, Joseph Collins, Chris Colvard, Dawid Czesak, Matthew Dempsky, Manoj Dongare, Peter Drake, Greg Drysdale, Douglas Eddy, Michael Forster, Louis Fuka, Angelo Furfaro, Bob Gabriels, Mircea Grecu, Siegmar Gross, RichardHall, David Hinkle, Ernie Homsy, Richard Howard, Zhang Hui, Chongwei Jin, James Johnson, Dale Jones, Ahmed Khademzadeh, PatricKik, George Kollias, Ashok Kumar, Robert Kwan, David Lanznar, Larry LaPointe, Jeppe Warberg Larsen, Daniel Lazzari, Cendey Lee,James Lee, Steffen Lehmann, David Lyng, Qichan Ma, Irina Marudina, Marijan Matic, Vincenzo Mele, Hildeberto Mendonça, ChristianMrugalla, Thejas Nair, Thomas Naumann, Raul Palma, Jeremy Palmer, David Pan, Ian Patterson, Diego Pérez, Bojan Petrovic, Łukasz
8/19/2019 Bug Fixes 8th Ed.
12/12
Piwko, Boaz Porat, Philip Puryear, Paul Pype, Derek Raimann, Etienne Richard, Dave Richards, Ken Rocha, Michael Roper, VickramSawh, Daniel Schuler, David Sletten, Zheng Song, Raj Subramanian, Greg Szpetkowski, Shunsuke Takamiya, Kenya Tanaka, Viktor Toman, Jim Tuller, Ingo Turnwald, Abhishek Vaid, Jan-Petter Vainionpää, Iurii Volchyn, Tielman de Villiers, R. Wahl, Andrew Wan, BrianWongchaowart, Kim Ming Yap, Mark Yasuda, Liang Yong, YanNi Yu, Yong Yu, Talal Zaidy, Keoki Zee, Jenny Zhou, Dejan Zivkovic,Steven Zollo, and (your name might go here) for their bug reports!
Bug Report Form
If you have found another bug in the book or in our code that is not mentioned in this bug list or the Core Java FAQ , then please send areport. Please do not bug us with JDK problems, though. Unfortunately, we cannot reply personally to each report, but we do read all youcomments.
Your name:
Your email address:
Edition: 8th Edition (Java SE 6) Volume 1
Page number:
Problem description:
To protect against spam robots, please answer this simple math problem:
8 * 3 = Submit Report Reset
Back to the Core Java page.
http://www.horstmann.com/corejava.htmlhttp://www.horstmann.com/corejava/faq.htmlRecommended