Name: gm110360 Date: 06/05/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :Microsoft Windows 2000
[Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
In Windows 2000, I have an AWT TextField which takes the
redirected Standard output. However, Printlns show up
strangely in it (They are inserted earlier than would be
expected). This behavior is not seen in JDK 1.3.1_02 on the
same machine.
REGRESSION. Last worked in version 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the sample application.
2.Press the button in it.
3.Press again.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Would expect to see the following result:
Test println
Test println2
Test println
Test println2
However, in JDK 1.4.0 on Win2k, the second (and subsequent)
button presses insert rather than append the text, resulting
in the following result:
Test println
Test printlnTest println
Test println2
2
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class TestPipe extends Frame implements WindowListener, ActionListener,
Runnable {
java.awt.TextArea outBox = new java.awt.TextArea();
Button print = new Button("Print to stdout");
private transient Thread outThread = new Thread(this,"Java Console Thread");
PrintStream stdout = System.out;
PipedInputStream out = new PipedInputStream();
public TestPipe() {
super("Java Console");
setLayout(new BorderLayout());
addWindowListener(this);
add("Center",outBox);
add("South",print);
print.addActionListener(this);
pack();
show();
try {
System.setOut(new PrintStream(new PipedOutputStream(out),true));
outThread.start();
} catch ( Exception e ) { e.printStackTrace(); }
}
public void actionPerformed(ActionEvent e) {
System.out.println("Test println");
System.out.println("Test println2");
}
public void dispose() {
try {
System.setOut(stdout);
outThread.stop();
} catch ( Exception e ) { e.printStackTrace(); }
}
public void run() {
if ( Thread.currentThread() == outThread ) {
byte[] buf = new byte[4096];
int n = 0;
while ( n != -1 ) {
try {
n = out.read(buf,0,4096);
outBox.append(new String(buf,0,n));
} catch ( Exception e ) { e.printStackTrace(); }
}
}
}
public void windowActivated(WindowEvent evt) {}
public void windowClosed(WindowEvent evt) {}
public void windowClosing(WindowEvent evt) {
this.dispose();
System.exit(0);
}
public void windowDeactivated(WindowEvent evt) {}
public void windowDeiconified(WindowEvent evt) {}
public void windowIconified(WindowEvent evt) {}
public void windowOpened(WindowEvent evt) {}
public static void main(String args[]) {
TestPipe console = new TestPipe();
}
public void finalize() {
try { outThread.stop(); } catch ( Exception e ) {}
}
}
---------- END SOURCE ----------
Release Regression From : 1.3.1_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 143759)
======================================================================