Name: gm110360 Date: 11/20/2001
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
My JApplets are not running the stop and destroy functions properly when
closing the browser.
For instance, the following code will work well in appletviewer:
import javax.swing.*;
public class JTodel extends javax.swing.JApplet {
public void destroy()
{
JOptionPane.showMessageDialog(this, "Destroying");
}
}
When terminating appletviewer, it will show a message box saying "Destroying",
and only after clicking OK will the appletviewer finally close its window.
With both MS Internet Explorer and Netscape, this behaviour does not happen at
all. No message box is presented and the browser simply quits. If I have two
open Internet Explorer windows and close the one with the applet, then despite
the window disappearing, the message box is shown and only disappears when
either I press OK or close the other browser window.
The following code also produces funny results:
public void destroy()
{
for (int i =0 ; i< 32000; i++)
{
System.out.println(Integer.toString(i));
}
}
When closing appletviewer, it will count up to (excluding) 32000 and only then
will appletviewer finally terminate.
With IE, it will count up to 4000 and quit.
It seems like destroy is called indeed, but somewhere on the way it is simply
discarded. Hence my tilte "JApplet destroy is destroyed". My uninformed hunch
(it is just a feeling) is that the applet or destroy is running on its own
thread and no-one is waiting for it to be normally terminated.
Deamon threads? :-)
This is not an ActiveX problem since I tried doing something simillar with an
OCX built in VB, like this:
Private Sub UserControl_Terminate()
MsgBox "Terminating"
End Sub
This works just like the applet over appletviewer. Besides that, Netscape,
which doesn't use ActiveX also presents the same bad behaviour.
I would consider this a rather serious bug, since it renders destroy to be
rather useless, mainly in a client-server environment where the client (the
applet which opened a socket to a server) needs to do some cleaning up before
logging-off (I cannot control if the user clicks the browser's close button, so
destroy will have to do the cleaning up).
(Review ID: 135922)
======================================================================
- duplicates
-
JDK-4630924 JPI(JVM) aborts without shutting down cleanly when browser is closed
-
- Closed
-
-
JDK-4747295 Plugin not blocking browser properly during browser shutdown or page switch
-
- Closed
-