classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnu.text.LineBufferedReader exposes bug in ORP or Classpath


From: Stuart Ballard
Subject: gnu.text.LineBufferedReader exposes bug in ORP or Classpath
Date: Wed, 29 Aug 2001 20:36:18 -0400

Sorry to send this to so many unconnected people, and doubly sorry to
Per if he's already on one of the two lists this is sent to.

I've been testing an application I'm writing using various free JVMs,
because I want to make sure it works on at least one of them before I
release it as free software itself. My application makes use of the
class gnu.text.LineBufferedReader from Kawa by Per Bothner, which is
available at

http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/kawa/gnu/text/LineBufferedReader.java?rev=1.3&content-type=text/plain&cvsroot=kawa

It appears that when I use LineBufferedReader under ORP with Classpath,
I lose the first character of every line except the first line - that
is, I lose the character following every newline. This behavior does not
happen on Kaffe or Sun/Blackdown.

I'd like to try to track down this problem, but I don't really
understand the code to LineBufferedReader terribly well. I can think of
three possible causes, but I don't know enough about ORP, Classpath or
LineBufferedReader to know how to track down which applies here.

1) Problem with the clever optimization that ORP does, causing some
check (eg the check for whether the CR is followed by an LF) to be
omitted or always return true, so that LineBufferedReader ignores the
character. This, of course, would be an ORP problem.
2) Problem with Classpath's implementation of <something>Reader (in my
testing, I always back it with a FileReader - the bug could be there)
which isn't exposed under simple usage patterns, but LineBufferedReader
does something more complicated (what?) that triggers it. This, of
course, would be a Classpath problem.
3) A bug or assumption in LineBufferedReader that isn't exposed under
Sun's Java or Kaffe. I consider this unlikely, but to be fair I have to
mention the possibility. I certainly don't understand the code well
enough to assert firmly that this *isn't* the case.

The test case I am using is as follows. Note that the bug is *not*
displayed when LineBufferedReader is removed and the FileReader is used
directly.

import java.io.Reader;
import java.io.FileReader;
import java.io.IOException;
public class OrpBug {
  public static void main(String[] args) throws IOException {
    for (int i = 0; i < args.length; i++) {
      readFile(args[i]);
    }
  }
  public static void readFile(String name) throws IOException {
    Reader fr = new gnu.text.LineBufferedReader(new FileReader(name));
    int ch = fr.read();
    while (ch != -1) {
      System.out.write(ch);
      ch = fr.read();
    }
    fr.close();
  }
}

If you run "orp OrpBug filename" where filename is any text file on your
machine, you should get an equivalent of "cat". You actually get an
equivalent of "cat | cut -c2-" (except that the very first character in
each file is not cut off).

The version of LineBufferedReader I am using is the one linked above. I
am using the debian packages of ORP and Classpath:
ii  orp            1.0.5-1        Java VM and JIT from Intel Research
Lab.
ii  orp-classpath  0.02-3         Free java class libraries (specific to
ORP J

Any suggestions as to how to track down this problem and fix it (in ORP,
Classpath or LineBufferedReader) would be much appreciated.

Thanks,
Stuart.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]