Welcome to the Core Java Bug List

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 as “First printing, December 2015”. 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 would want to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.

11th Edition Volume 1 (Java SE 9 - 11)

Page xxi
Change “Then we guide you through compiling and running three typical Java programs—a console application, a graphical application, and an applet—using the plain JDK, a Java-enabled text editor, and a Java IDE.” to “Then we guide you through compiling and running a console application and a graphical application. You will see how to use the plain JDK, a Java IDE, and the JShell tool.”
Page xxiv
Change "To start the registration process, go toinformit.com/register and log in" to "To start the registration process, go to informit.com/register and log in"
Page 11
Add a closing parenthesis after “a company that did much to make Java successful.”
Page 21
Change javac 9.0.4 to javac 11.0.1
Page 33
Change Version 9.0.1 to Version 11.0.1
Page 34
Change “You get a list of all methods that you can invoke on the generator variable:” to “You get a list of all methods that you can invoke with the Math class:”
Page 54
Change “Except, of course, when n is negative.” to “Except, of course, when n is odd and negative.”
Page 69
Change the method names empty and blank to isEmpty and isBlank.
Page 69
In the API note for the startsWith/endsWith methods, change “returns true if the string starts or ends with suffix.” to “returns true if the string starts with prefix or ends with suffix.”
Page 71
Change http://docs.oracle.com/javase/9/docs/api to https://docs.oracle.com/en/java/javase/11/docs/api
Page 72
Change jdk-9-docs to jdk-11-docs
Page 127
Change “A class is the template or blueprint from which objects are made. ” to “A class specifies how objects are made.”
Page 173/174
Move the C++ note to the end of Section 4.6.3. Change “In C++, you cannot directly initialize instance fields of a class. All fields must be set in a constructor. However, C++ has a special initializer list syntax, such as” to “C++ has a special initializer list syntax for constructing fields, such as”. Change “C++ uses this special syntax to call field constructors.” to “C++ uses this special syntax to avoid unnecessary invocations of no-argument constructors.”
Page 184
Change PackageText to PackageTest (2x) in the directory tree
Page 196
Change
 ├─ versions
 ├─ 9
 │  ├─ Application.class
 │  └─ BuildingBlocks.class
 └─ 10
    └─ BuildingBlocks.class
to
 └─ versions
    ├─ 9
    │  ├─ Application.class
    │  └─ BuildingBlocks.class
    └─ 10
       └─ BuildingBlocks.class
Page 212
Change “If the subclass constructor does not call a superclass constructor explicitly, the no-argument constructor of the superclass is invoked. If the superclass does not have a no-argument constructor and the subclass constructor does not call another superclass constructor explicitly, the Java compiler reports an error.” to “When a subclass object is constructed without explicit invocation of a superclass constructor, the superclass must have a no-argument constructor. That constructor is invoked prior to the subclass construction.”
Page 220
Change “then the compiler consults the method table” to then the virtual machine consults the method table
Page 282
Remove the second bullet void setAccessible(boolean flag)
Page 292
Change the paragraph starting with “Note that this problem does not arise” to “Note that this problem does not arise if you extend an immutable class. Suppose you have an immutable date class, similar to LocalDate but not final. If you form a Holiday subclass, there is no method that can turn a holiday into a nonholiday.”
Page 310
In the Caution note, change Objects.equals to Object.equals
Page 331
In the second column, change Integer::valueOf(x) to Integer.valueOf(x) and Integer::sum(x, y) to Integer.sum(x, y)
Page 328
Change new LocalDate to LocalDate.of (2x)
Page 328
Change requireNonNullOrElse to requireNonNullElse, requireNonNullOrElseGet to requireNonNullElseGet
Page 340
Change Comparator.comparing(Person::getMiddleName(), Comparator.nullsFirst(. . .)) to Comparator.comparing(Person::getMiddleName, Comparator.nullsFirst(. . .))— that is, no parentheses after getMiddleName
Page 345
Change “by calling it outer” to “by calling it outer”—italic, not monospace
Page 361
Change “Now add the names of the classes to a UTF-8 encoded text file in a file in the META-INF/services directory whose name matches the fully qualified class name.” to “Now add the names of the classes to a UTF-8 encoded text file in a file in the META-INF/services directory whose name matches the fully qualified interface name.”
Page 380
Change
String readData(BufferedReader in) throws FileFormatException
to
String readData(Scanner in) throws FileFormatException
Page 407
Change

The default configuration file is located at

conf/logging.properties

(or at jre/lib/logging.properties prior to Java 9).

to

The default configuration file is located at jdk/conf/logging.properties (or at jre/lib/logging.properties prior to Java 9).

Page 428
Change /opt/jdk-9.0.1/lib/modules to /opt/jdk-11.0.1/lib/modules
Page 453
Change
public static <T extends Throwable> void d 
   {
      do work
   }
to
public static <T extends Throwable> void doWork(T t) throws T // OK
{
   try
   {
      do work
   }
Page 453
Change Logger.global.info(. . .); to Logger.getGlobal().info(. . .);
Page 463
Change “a better job with the min method” to “a better job with the minmax method”. Change
public static <T extends Comparable<T>> T min(T[] a)
to
public static <T extends Comparable<T>> Pair<T> minmax(T[] a)
and
public static <T extends Comparable<? super T>> T min(T[] a) . . .
to
public static <T extends Comparable<? super T>> Pair<T> minmax(T[] a)
Page 496
In Figure 9.5, change ArrayQueue (or ArrayDeue in some printings) to ArrayDeque
Page 511
Change “(a number between 0.0 and 1.0 that determines at what percentage of fullness the hash table will be rehashed into a larger one).” to “. If the ratio size/capacity exceeds the load factor, the hash table will be rehashed into a larger one.”
Page 538
In the API notes for java.util.List, change the last bullet from static <E> Set<E> of(E... elements) to static <E> List<E> of(E... elements)
Page 556
Change "9.0.1" to "11.0.1"
Page 561
Change “Java 9.0.1” to “Java 11.0.1”
Page 624
Change “prorgram” to “program”
Page 624
Change java.util.preferences to java.util.prefs
Page 628 preferences/ImageViewer.java
Change line 60 from
node.put("image", image);      
to
if (image != null) node.put("image", image);
Page 756, 768
Change private var to private Lock
Page 785 blockingQueue/BlockingQueueTest.java
Change e.g. /opt/jdk-9-src to e.g. /opt/jdk-11-src
Page 789
Change “The concurrent hash map can efficiently support a large number of readers and a fixed number of writers. By default, it is assumed that there are up to 16 simultaneous writer threads. There can be many more writer threads, but if more than 16 write at the same time, the others are temporarily blocked. You can specify a higher number in the constructor, but it is unlikely that you will need to.” to “The concurrent hash map can efficiently support a large number of readers and a bounded number of writers.”
Page 795
Change
U searchKeys(long threshold, BiFunction<? super K, ? extends U> f)
U searchValues(long threshold, BiFunction<? super V, ? extends U> f)
U search(long threshold, BiFunction<? super K, ? super V,? extends U> f)
U searchEntries(long threshold, BiFunction<Map.Entry<K, V>, ? extends U> f) 
to
U searchKeys(long threshold, Function<? super K, ? extends U> f)
U searchValues(long threshold, Function<? super V, ? extends U> f)
U search(long threshold, BiFunction<? super K, ? super V,? extends U> f)
U searchEntries(long threshold, Function<Map.Entry<K, V>, ? extends U> f) 
(i.e. 3x drop Bi)
Page 797
Change
values.parallelSort(values.length / 2, values.length);
to
Arrays.parallelSort(words, words.length / 2, words.length);
Page 801
Change Integer result = task.get(); to Integer result = futureTask.get();
Page 817
Change public void CompletableFuture<String> to public CompletableFuture<String>
Page 820
Change the last entry in the last column of Table 12.4 to: “Complete after any of the given futures completes, yielding its result.”
Page 833
Change “Call builder.redirectIO() to make this setting for all three streams” to “Call builder.inheritIO() to make this setting for all three streams”
Page 834
Change process.waitfor(delay, TimeUnit.SECONDS) to process.waitFor(delay, TimeUnit.SECONDS)—an uppercase F in waitFor
Page 835
Change Process.current() to ProcessHandle.current()

11th Edition Volume 2 (Java SE 9 - 11)

Page 2, 4, 8, 23, 27, 45
Change new String(Files.readAllBytes to Files.readString and remove the subsequent , StandardCharsets.UTF_8)
Page 7
Add a semicolon after wordList.remove(s), changing words.forEach(s -> if (s.length() < 12) wordList.remove(s)); to words.forEach(s -> {if (s.length() < 12) wordList.remove(s);});
Page 39 collecting/DownstreamCollectors.java
Remove Line 57 locales = Stream.of(Locale.getAvailableLocales());
Page 46, 47
Change “yields the sum, average, maximum, or minimum” to “yields the sum, count, average, maximum, or minimum” (3x)
Page 65
For greater clarity, change the code block
var din = new DataInputStream(
   pbin = new PushbackInputStream(
      new BufferedInputStream(
         new FileInputStream("employee.dat"))));
to
var pbin = new PushbackInputStream(
   new BufferedInputStream(
      new FileInputStream("employee.dat")));
var din = new DataInputStream(pbin);
Page 70
Change the first bullet from PrintWriter(Writer out) to PrintWriter(OutputStream out)
Page 71
Change
var content = new String(Files.readAllBytes(path), charset);
to
var content = Files.readString(path, charset);
Page 73
Change
Employee[] readData(BufferedReader in)
to
Employee[] readData(Scanner in)
Page 101
Change
public void readExternal(ObjectInputStream in)
      throws IOException, ClassNotFoundException;
public void writeExternal(ObjectOutputStream out)
      throws IOException;
to
public void readExternal(ObjectInput in)
      throws IOException, ClassNotFoundException;
public void writeExternal(ObjectOutput out)
      throws IOException;
Page 112
Change “If you want to read the file as a string, call readAllBytes followed by” to “As already mentioned in Section 2.1.6, you can read the content of a text file as”. Replace the code line that follows with
var content = Files.readString(path, charset)
Two times, change
Files.write(path, content.getBytes(charset)
to
Files.writeString(path, content, charset
and, for consistency, change
Files.write(path, lines);
to
Files.write(path, lines, charset);
Page 113
In the API note, add bullets below the first and third bullet respectively.
Page 123
Change
static FileVisitResult postVisitDirectory(T dir, BasicFileAttributes attrs)
to
static FileVisitResult postVisitDirectory(T dir, IOException exc)
Page 126
Change
get(byte[], int offset, int length)
to
get(byte[] bytes, int offset, int length)
Page 133
Change
0 = mark = position = limit = capacity
to
0 ≤ markpositionlimitcapacity
Page 146
Change String match = input.group(); to String match = matcher.group();
Page 160
Change
URL u = . . .;
Document doc = builder.parse(u);
to
URL u = . . .;
Document doc = builder.parse(u.toString());
Page 189
Change </database> to </head>
Page 192 xpath/XPathTest.java
In line 63, change XPathEvaluationResult.XPathResultType.NODESET to XPathEvaluationResult.XPathResultType.NODE
Page 193
Change the bullet XPath newXpath() to XPath newXPath()
Page 203 stax/StAXTest.java
In line 9, change hyperlinks links to hyperlinks
Page 212 write/XMLWriteTest.java
Insert the following lines after line 33
    * @param drawingWidth the width of the drawing in pixels
    * @param drawingHeight the width of the drawing in pixels
Insert the following lines after line 72
    * @param doc the document to be written
    * @param filename the name of the destination file
Page 213
Replace lines 90-92 with
    * Uses StAX to write an SVG document with a random drawing.
    * @param drawingWidth the width of the drawing in pixels
    * @param drawingHeight the width of the drawing in pixels
    * @param filename the name of the destination file
Page 214
In the API documentation for javax.xml.stream.XMLOutputFactory, change the bullets
XMLStreamWriter createXMLStreamWriter(OutputStream in)
XMLStreamWriter createXMLStreamWriter(OutputStream in, String characterEncoding)
XMLStreamWriter createXMLStreamWriter(Writer in)
XMLStreamWriter createXMLStreamWriter(Result in)
to
XMLStreamWriter createXMLStreamWriter(OutputStream stream)
XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding)
XMLStreamWriter createXMLStreamWriter(Writer writer)
XMLStreamWriter createXMLStreamWriter(Result result)
Page 217
Change 000</salary> to 000.0</salary> (3x)
Page 290
Change
SELECT Books, Books.Publisher_Id, Books.Price, Publishers.Name, Publishers.URL
to
SELECT Books.Title, Books.Publisher_Id, Books.Price, Publishers.Name, Publishers.URL
Page 311, 312
Change
SELECT Books.Price, Books
to
SELECT Books.Price, Books.Title
(3x)
Page 358
Remove the second and third bullet long toSeconds(). Change
long to(Days|Hours|Minutes|Seconds|Millis|Nanos)Part()
to
long toDaysPart()
Change Instant to Duration (3x) and “an instant” to “a duration”
Page 362
Change “yields an instant that is the given amount away from this Instant” to “yields a LocalDate that is the given amount away from this LocalDate. ”
Page 363
Change “yields a LocalDate” to “yields a Period
Page 366
Change “yields an instant that is the given amount away from this Instant” to “yields a LocalTime that is the given amount away from this LocalTime. ”
Page 370
Change “yields an instant that is the given amount away from this Instant” to “yields a ZonedDateTime that is the given amount away from this ZonedDateTime. ”
Page 397 dateFormat/DateTimeFormatterTest.java
Change buttons to parse the text field contents, and a "lenient" check box to and buttons to parse the text field contents
Page 401
Change
static DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle, FormatStyle timeStyle)
to
static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateStyle, FormatStyle timeStyle)
Page 409
Change “ND, NKD, NC, or NKC” to “NFD, NFKD, NFC, or NFKC”
Page 418
Change the third line after “tries to load the following bundles” from baseName_currentLocaleLanguage_defaultLocaleCountry to baseName_defaultLocaleLanguage_defaultLocaleCountry
Page 446
Change “the JavaScript SimpleGreeter class” to “the JavaScript Greeter class”
Page 492
Remove the line * @param cg the class
Page 497
Change (loader, className, cl, pd, data) -> to
new ClassFileTransformer() {
         public byte[] transform(ClassLoader loader, String className, Class<?> cl,
            ProtectionDomain pd, byte[] data) throws IllegalClassFormatException
and add another } to });.
Page 505 Figure 1
Change ch15.sec04 to v2ch09.requiremod
Page 511
Change “Is is expected” to “It is expected”
Page 535
In Figure 10.2, change “Extension class loader” to “Platform class loader”
Page 550
Change “ the restricted permissions of the applet class” to “ the restricted permissions of the servlet class”
Page 568
After “The meaning of these keywords is given by the following algorithm:”, add:
  1. The modules are executed in turn, until a sufficient module succeeds, a requisite module fails, or the end of the module list is reached.
  2. Authentication is successful if all required and requisite modules succeed, or if none of them were executed, if at least one sufficient or optional module succeeds.
Page 574
Change
SimpleLoginModule required pwfile="password.txt";
to
SimpleLoginModule required pwfile="jaas/password.txt";
Page 575
Change the instructions to
javac jaas/*.java
jar cvf login.jar jaas/JAAS*.class jaas/Simple*.class
jar cvf action.jar jaas/SysPropAction.class
and
java -classpath login.jar:action.jar \
   -Djava.security.policy=jaas/JAASTest.policy \
   -Djava.security.auth.login.config=jaas/jaas.config \
   jaas.JAASTest
Page 576
After line 24, add
   public SimplePrincipal(String descrAndValue)
   {
      String[] dv = descrAndValue.split("=");
      this.descr = dv[0];
      this.value = dv[1];
   }
Page 596
Change
keytool -importcert -keystore cindy.certs -alias alice -file acmeroot.pem
to
keytool -importcert -keystore cindy.certs -alias acmeroot -file acmeroot.pem
Page 608
Change “encrypted method” to “encrypted message”
Page 639
Change String getStringValue() to String getStringValue(int index)
Page 650 tableCellRender/ColorTableCellEditor.java
Change “tell caller is is ok” to “tell caller it is ok”
Page 682
In line 161, change @param the class to be described to @param c the class to be described
Page 708
In Line 151, change ointCount to pointCount
Page 765
Change http://bugs.sun.com /bugdatabase/view_bug.do?bug_id=6183251 to https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6183251
Page 794
In the sixth row of the table, change TEXT_HML_HOST to TEXT_HTML_HOST
Page 811
Change “As in the previous chapter, we” to “We”
Page 813 Listing 12.3
Line 11 add a comma: printf("Hello, Native World!\n");
Page 815, 816
Change javah to javac -h
Page 827
In the Caution note, change id_a = (*env)->GetFieldID(env, cls, "a", ". . ."); to id_a = (*env)->GetFieldID(env, class_X, "a", ". . .");
Page 838
In line 66, change ps.print(str) to out.print(str)
JavaFX Bonus Chapter Page 47
In Figure 13.15, switch Label and Labeled, and make PasswordField extend TextField
JavaFX Bonus Chapter Page 94
Change
task.setOnFailed(event -> status.setText("Failed due to ") + task.getException());
to
task.setOnFailed(event -> status.setText("Failed due to " + task.getException()));

Thanks to Carlos Eduardo Villanueva Altuna, Mark Ayling, Jessica Cunningham, Dariusz Daćko, Inge Frissen, Pavlo Gotsonoga, Martin Harrigan, Michael Kaelbling, Stephen Kalinin, Daniel King, Oleksii Klochko, Suresh Kumar, Kendrew Lau, Qiang Li, Ke Ma, Irene Mitin, Marv Mollnow, Sy Pham, Ivan Ponomarev, Cesar Rocha, Jinkai Ruan, Eric Rybarczyk, Mark Summerfield, Vyacheslav Usov, Semyon Vasilkov, Matthieu Vincenten, Andy Walsh, Eric Wang, Piotr Winiarek, Phuoc Dong Xuai, Henry Yu, Hongyuan Zhang, Wei Zhang, 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 a report. Unfortunately, I cannot reply personally to each report, but I do read all your comments.

Your name:

Your email address:

Edition:
Page number:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =