System.err peculiarity
David Young
dyoung at mork.uni.uiuc.edu
Wed Jul 15 12:12:06 PDT 1998
System.err isn't behaving as I've come to expect. I have these
two classes:
public class Kaffe {
public static void main(String[] arg) {
if (arg.length < 3) {
System.err.print("java RTrace.dof filename.ppm xres yres\n");
System.exit(1);
}
}
}
public class Kaffe2 {
public static void main(String[] arg) {
if (arg.length < 3) {
System.err.print("java RTrace.dof filename.ppm xres yres\n");
System.err.flush();
System.exit(1);
}
}
}
I comple and run them like so:
baltazar:~/java> javac Kaffe.java Kaffe2.java
baltazar:~/java> java Kaffe
baltazar:~/java> java Kaffe2
java RTrace.dof filename.ppm xres yres
baltazar:~/java> /usr/local/jdk1.1.1/bin/java Kaffe
java RTrace.dof filename.ppm xres yres
baltazar:~/java> /usr/local/jdk1.1.1/bin/java Kaffe2
java RTrace.dof filename.ppm xres yres
baltazar:~/java>
(Plain 'java' is actually a shell script that runs kaffe.
/usr/local/jdk1.1.1/bin/java is the JDK interpreter.)
I expect the output of Kaffe to be identical to the output of
Kaffe2 for a number of reasons. First, that's the output that Sun's
interpreter produces. Second, it's typical for standard output streams
to be flushed on a carriage return. Third, it's typical for the standard
error stream to be flushed on every character (or at least on every
write()). Fourth, it's typical for standard output streams to be flushed
when they are closed, and System.exit(1) presumably closes the standard
output streams. In my opinion, the present behavior of Kaffe's System.err
is incorrect with respect to the assumptions that any reasonable programmer
would make about its operation.
Dave
--
David Young * dcy2 cornell edu
More information about the kaffe
mailing list