System.err peculiarity

Archie Cobbs archie at whistle.com
Wed Jul 15 11:44:09 PDT 1998


David Young writes:
> 	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

Try the patch below and see if it helps. IMHO this (or equivalent)
should be committed.

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

Index: libraries/javalib/java/lang/System.java
===================================================================
RCS file: /cvs/mod/net/kaffe/libraries/javalib/java/lang/System.java,v
retrieving revision 1.1.1.1
diff -c -u -r1.1.1.1 System.java
--- System.java	1998/07/14 16:49:32	1.1.1.1
+++ System.java	1998/07/15 18:42:50
@@ -17,6 +17,7 @@
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
+import java.io.IOException;
 import java.util.GregorianCalendar;
 import java.util.SimpleTimeZone;
 import java.util.Properties;
@@ -40,7 +41,20 @@
 	// Setup I/O
 	setIn(new BufferedInputStream(new FileInputStream(FileDescriptor.in), 128));
 	setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 128), true));
-	setErr(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128), true));
+	setErr(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128)
+
+	{
+	  public void write(byte[] ary, int off, int len) throws IOException {
+	    super.write(ary, off, len);
+	    this.flush();
+	  }
+	  public void write(byte b) throws IOException {
+	    super.write(b);
+	    this.flush();
+	  }
+	}
+
+	, true));
 
 	// Initiate the timezone & calendar.
 	new SimpleTimeZone(0, "GMT");


More information about the kaffe mailing list