A small java.io bugfix
robilad at yahoo.com
Mon Jan 10 22:35:57 PST 2000
attached you'll find a patch for current CVS version
of Kaffe. This one fixes:
The default size of the buffered reader did not match
Sun's. The JDK 1.2 documentation doesn't say anything
about it besides
"The buffer size may be specified, or the default size
may be used. The default is large enough for most
On the other hand I found a reference in "The Java
Class Libraries, Second Edition, Vol 1", at p 193,
"There are two forms of the constructor for
*BufferedReader*. The first form constructs for the
reader *in* a buffered reader that has the default
buffer size of 8K characters."
So I fixed that ...
method mark(int readAheadLimit):
According to The Java Class Libraries, Second Edition,
Vol. 1, the method mark(int readAheadLimit) in the
class Reader should throw an IOError in the default
implementation. Our version doesn't do anything, so of
course it doesn't throw the required IOException.
I also made it throw the IOException with the same
message as Sun's JDK 1.2 does.
There is a possible race condition when two threads
use the same Reader and both try to read() at the same
time. Imagine the following situation:
A class PseudoReader inherits form Reader and
implements the abstract methods close() and read(char
, int, int)
In its read implementation, it uses locking based on
the inherited class variable lock, while it writes
character into the buffer, so that's alright.
Thread A calls read(), which in turn calls
read(single, 0, 1), and gets character 'a' stored into
inherited class variable single, but gets interrupted
after it has released the lock and before it could
return from the function read(char , int, int)
Thread B goes into action and calls read() on the same
PseudoReader, and gets character 'b' stored into
single. It returns 'b' happyly. The inherited class
variable single == 'b' now.
Thread A continues and returns from the read function
as well. Unfortunately, its call to read() returns
'b', which is wrong. (According to JDK 1.2 behaviour,
and "The Java Class Libraries, Second Edition, Vol 1"
documentation for Reader.lock)
It should return false by default and not true,
according to JDK 1.2 behaviour, and "The Java Class
Libraries, Second Edition, Vol 1".
I've made it throw the same message the JDK does.
method skip(long n):
skip did not block until some characters are
fixed it to produce the string in the same format the
Appropriate regression tests are in the works.
happy checking in,
"Success means never having to wear a suit"
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3002 bytes
Url : http://kaffe.org/pipermail/kaffe/attachments/20000110/b5f87213/attachment-0003.bin
More information about the kaffe