JDK-6296152 : System.err cannot print ThreadDeath
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2005-07-13
  • Updated: 2010-05-10
  • Resolved: 2005-10-25
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
in the following code, e.printStackTrace() does nothing on Solaris but it works on Windows XP.

class Death {
	public static void main(String[] args) throws Throwable{
		Thread t = new Thread() {
			public void run() {
                            try {
                                while(true);
                            }catch(ThreadDeath e) {
				e.printStackTrace();
				System.out.println(e);
				throw e;
                            }finally {
				System.out.println("finally reached");
                            }
			}
		};
                t.start();
		Thread.sleep(2000);
		System.out.println("state " + t.getState() + "\tisAlive " + t.isAlive());
		t.stop();
		System.out.println("state " + t.getState() + "\tisAlive " + t.isAlive());
		Thread.sleep(2000);
		System.out.println("2sec later state " + t.getState() + "\tisAlive " + t.isAlive());
	}
}

###@###.### 2005-07-13 04:28:52 GMT

Comments
EVALUATION This is Solaris-specific behavior related to interruptible i/o, caused by the fact that the thread is in an interrupted state after being stopped. This is a dupe of 4329256 ("interrupted thread no longer produces output") and the fact that Thread interruption is on for a stopped thread is JVM CR 6194515 ("Thread.isInterrupted() returns true for stopped threads"). The latter CR has been closed/will not fix, so this behavior will persist until/unless CR 4385444 ("InterruptedIOException should not be required by platform specification") is addressed in some manner.
25-10-2005

EVALUATION This is very likely due to interruptible IO being enabled only on Solaris. e.g. Thread.currentThread().interrupt(); System.out.println("Hello"); will print nothing on Solaris. Looks like a dup of 4329256: interrupted thread no longer produces output (but this investigation is superficial and needs to be confirmed)
03-08-2005