Errata

Java Virtual Machine

Errata for Java Virtual Machine

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page page
} The java -verify option doesn't in fact turn on verification

any more. Now you have to use AppletViewer, or write your own class
loader, or use something akin to JavaRunner (see Java Security), or
java.security.Main in Java 1.2

Anonymous   
Printed Page 3
para. 1, lines 2-3: "... purely interpreted languages (such as

JavaScript, Lingo, Perl, and Tcl)" should be

"... purely interpreted languages (such as JavaScript, Lingo, and Tcl)"

(Perl is not purely interpreted.)

Anonymous   
Printed Page 6
Table 1-1, last row: "int2short" should be "i2s" and

"d2I" should be "d2i"

Anonymous   
Printed Page 28
Table 2-1, last row: "private protected" combination is no longer

allowed in the published Java standard

Anonymous   
Printed Page 28
code sample 3, line 1: in "<init>(Ljava/lang/String;)" the V

(void return type) is missing

Anonymous   
Printed Page 31
para.3 , line 1: "The type descriptor" should be "the type"

Anonymous   
Printed Page 32-33
comment from reader: Why does your implementation compute 10-i?

Presumably it is so the final branch can be done against 0 instead of
having to subtract from 10. But, you have to do the substraction earlier
anyway for printing. Perhaps this is the code the compiler generated, but
is a very confusing first example. I recommend storing i and subtracting
from 10 at the end if you need to for the comparison.

Anonymous   
Printed Page 36
All the places you reference variable 3, you should be

referencing variable 2.

Anonymous   
Printed Page 36
I think I have found a bug on page 36. The previous examples on

pages 34 and 35 use the text:

iinc 2 -1
iload_2
ifne Loop

however, on page 36, the test uses local variable 3 instead of local
variable 3.

Anonymous   
Printed Page 38
the dup command had me stumped for a long time. Aside from the

issue about not being able to store/load it (which you should comment
on here), your comment threw me for a loop. It says 'dup the instance
and call its constructor'. I assumed that that comment applied just
to 'dup'! Even when I realized that the 'call its constructor' part
applied to the following code, it still took me quite some time to
realize you meant 'dup the reference'. Since I didn't know the JVM, I
assumed that there was a command to duplicate an instance. It didn't
make any sense, but there it was. Finally, explain that you must use
dup, or else all references go away, and you need to keep one for the
putfield command.

Anonymous   
Printed Page 57
Table 3-5, row 3: "?2I" should be "?2i" (the "I" should be lowercase)

Anonymous   
Printed Page 77
Table 4-3 makes a fairly serious error: it swaps the values of

CONSTANT_String and CONSTANT_Class. An insignificant error: it
reports the structure as a CONSTANT_Classref, when the Sun spec refers
to it as a CONSTANT_Class.

Anonymous   
Printed Page 77
CONSTANT_Class is called "CONSTANT_Classref" and its value is

swapped with that of CONSTANT_String. The correct table appears on p.179.

Also, I saw no mention of the fact that the count field for the constant
table actually contains the count+1. Perhaps I missed it?

Anonymous   
Printed Page 78
Table 4-4: Doesn't a CONSTANT_Utf8 take a word specifying the

number of bytes in the ensuing string?

Anonymous   
Printed Page 82
Table 4-5, title, "Constant pool of class "out"":

this title actually belongs to Table 4-8

Anonymous   
Printed Page 87
2nd P. You have the major/minor version mixed up somewhere.

Either the byte code is wrong or the description is wrong.

Anonymous   
Printed Page 87
Byte code: the spacing of the dashes is wrong below 'tag = 1'

Anonymous   
Printed Page 87
Byte code: the second tag type is wrong. You have

CONSTANT_Class, and it should be CONSTANT_FieldRef.

Anonymous   
Printed Page 88
Table 4-8: I'd prefer the table entry numbers to be in hex so I

could easily reference them from the byte code. As it is, I had to
keep converting to decimal. Anyone that is reading this section in
any detail better know hex, or forget it!

Anonymous   
Printed Page 88
Table 4-8 entries 19 and 20

Table entry 19 should probably be changed as follows:

Original:
19 | Class | name = "out"

Corrected:
19 | Class | name = (8) "out"
****

Table entry 20 should probably be changed as follows:

Original:
20 | Utf8 | name = "java/lang/System"

Corrected:
20 | Utf8 | bytes = "java/lang/System"
*****

Anonymous   
Printed Page 89
1st byte code: 2nd line spacing of dashes is wrong.

Anonymous   
Printed Page 89
Why doesn't the access_flags for this (and the following methods)

also have ACC_SUPER? The description on page 84 specifically said
that 'all modern compilers should set the ACC_SUPER bit ...' Either
fix this or the description of the bit.

Anonymous   
Printed Page 90
byte code: Spacing of dashes on 2nd line is messed up.

Anonymous   
Printed Page 109
The authors state 'In Ansi C, a 64-bit integer is usually

declared as a "long long"...'. If I recall correctly, 'long long' is
not an ANSI C datatype, but a common extension.

Anonymous   
Printed Page 140
Table 8-4, row -6: "d2I" should be "d2i"

Anonymous   
Printed Page 146
text above Table 9-3: return value is either 0, or +1, OR -1

Anonymous   
Printed Page 151
the example Point class seems a little strange. What kind of

length are we figuring? Seems to me x and y are the cartesian
coordinates of a point in 2-space. I could make more sense out of it
if the class were named RightTriangle, where length calculates the
hypotenuse, or if length took a reference to another Point as a
parameter.

Anonymous   
Printed Page 152
code sample 1, line 3: ".limit vars 3" should be

".limit locals 3"

Anonymous   
Printed Page 173
last line, (byte1 << 8) + byte2, and

Anonymous   
Printed Page 174
2nd line, (byte1 << 24).....

These code fragments won't actually work as described.

When Java applies the << and (I think) the + operators it is
performing widening conversions on the byte values first.
Because Java normally sign extends bytes values when it converts them
to int or long values this code can result in negative numbers.

One way of doing what you require is to use the & operator which
(although I can't find this documented anyway - not even in the
OReilly book on the language spec!) seems to do a widening conversion
to an int or a long *without* extending the sign bit. So I would
propose this instead:

((byte1 & 0xff) << 8) | (byte2 & 0xff)

or this:

((byte1 & 0xff) << 8) + (byte2 & 0xff)

Anonymous   
Printed Page 176

The text reads:

"For interfaces, super_class is often (but not necessarily) the
class java.lang.Object."

According to Sun's Java Virtual Machine Specification posted on
their web site (Section 4.1),
<http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html>,
super_class must *always* be java.lang.Object. The fact that the
O'Reilly book is careful enough to say that this isn't always the case
is curious, but this appears to be a genuine error to me.

Anonymous   
Printed Page 178
In the grammar, the <data_type> should probably be a

<field_type> again (or v.v.)?

Anonymous   
Printed Page 186
Under "Field Attributes":

"Only one field attribute is currently recognized: the "ConstantValue"
attribute. This gives the initial value of a -STATIC- field."

I have written a code which disassembles .class bytecode. I found hat
it's not STATIC but FINAL variable, whose value is stored by
ConstanValue attribute.

Anonymous   
Printed Page 202
The Exceptions list for the anewarray instruction is missing

"OutOfMemoryError - insufficient memory to allocate the array". This is
correct in new, newarray, and multianewarray.

Anonymous   
Printed Page 223
the second-to-last sentence under "Description" of the dcmpl

instruction should change from:

"if either numbers is NaN, the integer 1 is pushed onto the stack"

to:

"if either number is NaN, the integer -1 is pushed onto the stack"

Anonymous   
Printed Page 248
para. under "Description", line -1: "the integer 1" should be

"the integer -1"

Anonymous   
Printed Page 263
there is an error at the top of the page. It says that

'getstatic' pops an objectref off the stack, which is not true. The
diagram on page 262 which shows the stack is, however, correct.

Anonymous   
Printed Page 315
invokevirtual: the stack order of the runtime arguments is

incorrect (wrong order).

Anonymous   
Printed Page 322
1st paragraph - Description

This mistake is in the ishr instruction - integer arithmetic shift
right. The description states that value 1, the first value poped off the
stack should be shifted right by the amount indicated in the low 5 bits of
value 2. In fact, value 2 should be shifted right by the amount indicated
in the low 5 bits of value 1.

Anonymous   
Printed Page 386
There is a bug in the description of the tableswitch opcode: it

should say (high-low+1), not vice-versa.

Anonymous   
Printed Page 388
There is a bug in your description of the wide version of iinc

the <n> operand should be a signed short.

{chapter 4} I've just noticed that the Java 1.1 ClassLoader has a
slightly different interface than the 1.0 ClassLoader (the defineClass
method has been deprecated and a new method is in place). This will
need to be reflected in Chapter 4 at some point.

Anonymous