Name: nt126004 Date: 10/31/2002
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
Service Pack 3 installed
French version of Operating System and Service Pack
A DESCRIPTION OF THE PROBLEM :
System.exit(0) doesn't end the JVM for a Swing application
(not tested with other kinds) when the following conditions
are true together :
- A shutdownhook has been registered
- The Java Web Start console has been activated
The windows (application window and JWS console window) get
closed, but the process (javaw.exe) never terminates and
the shutdownhook never gets called.
This happends with JDK 1.4.1 and JWS 1.2.
With the following combinations, the bug does not occur,
i.e. the JVM terminates normally:
JDK 1.4.0 and JWS 1.2
JDK 1.4.1 and JWS 1.0.1
JDK 1.4.0 and JWS 1.0.1
A very problematic side-effect of this is :
If the application is an RMI-server, any RMI-call will
indefinitly block the caller, i.e. the RMI-call never
returns and never throws an exception.
I was unable to reproduce this on Solaris with any combination
of jvm and javaws.
REGRESSION. Last worked in version 1.0.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. turn on "Display Java Console" in Java Web Start
2. run the "sdh" (see below) application via Java Web Start
3. hit the big exit button (or close the window)
4. check if the process is still running
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected : JVM must terminate (javaw.exe must terminate)
Actual : JVM does not terminate
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sdh;
import java.util.Date;
import java.io.*;
public class Application1 {
public static void fappendLine(String fileName, String line) {
File f = new File(fileName);
try {
f.createNewFile();
FileWriter fw = new FileWriter(f,true);
fw.write(line+System.getProperty("line.separator"));
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
// add shutdownhook
Runtime.getRuntime().addShutdownHook(
new Thread() {
public void run() {
System.out.println("Shutdown-hook activated");
fappendLine("c:\\sdh.txt","Shutdown-hook activated");
try {Thread.sleep(3000);} catch(Exception e) {} // delay shutdown 3s
}
}
);
Frame1 frame = new Frame1();
frame.setSize(300,300);
frame.validate();
frame.setVisible(true);
}
}
--------------------------------------------------------------------
package sdh;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame {
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
JButton b = new JButton("Exit");
b.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
);
getContentPane().add(b);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Don't use the Java Web Start Console or close it before
exiting the application.
(Review ID: 166366)
======================================================================