JDK-8023095 : Applet with legacy_lifecycle=true and jdwp properties destroyed on browseaway
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 7u40
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • Submitted: 2013-08-14
  • Updated: 2015-06-03
  • Resolved: 2014-10-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40 b12Fixed 9Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
  From Java console:

Java Plug-in 10.40.2.38
Using JRE version 1.7.0_40-ea-b38 Java HotSpot(TM) Client VM

ADDITIONAL OS VERSION INFORMATION :
Windows 7 (Microsoft Windows [Version 6.1.7601])

A DESCRIPTION OF THE PROBLEM :
Using an applet configured with the legacy_lifecycle parameter set to true, so that an applet frame remains open even when the user browses away from the original page, the applet is destroyed on browse-away if the Java control panel is configured with the JDWP properties used to enable remote debugging.

Without the JDWP properties configured, the applet remains alive even after browsing off the applet page.

This last worked fully in 7u17, then JDWP remote debugging stopped working in 7u21 and 7u25 while the legacy_lifecycle=true behavior continued to work (that is, if JDWP props were set, browse-away would not destroy the separate applet frame, but JDWP itself was in-op). Now in 7u40-ea-b38, JDWP works again, but if JDWP props are configured, applet with legacy_lifecycle=true is destroyed on browse-away.

REGRESSION.  Last worked in version 7u17

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an applet that opens a separate frame as a test that the applet remains running when you browse off the HTML page. With 7u40, the applet must also be jar'ed.

In the HTML applet tag, set the  " legacy_lifecycle "  parameter to  " true " .

In the Java control panel -> Java tab -> View -> Java Runtime Environment Settings dialog, add these JDWP props as the runtime parameters:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

Load the HTML page into the browser, so the applet loads, accepting any required security prompts.

Once the applet frame has been displayed, navigate to another website. The applet frame should remain alive.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The applet should remain alive when browsing away from the HTML page.
ACTUAL -
The applet is destroyed on browse-away.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages, but when problem occurs, Java console has this output (at tail end):

security: SSV validation: running: 1.7.0_40-ea, requested: null, range: null
network: Created version ID: 1.7.0.40
network: Created version ID: 1.7.0.40
security: continue with running version
network: Created version ID: 1.7.0.40.ea
network: Created version ID: 1.7
network: Created version ID: 2.2.40
security:  --- parseCommandLine converted : -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
into:
[-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005]
network: Created version ID: 1.9
network: Created version ID: 1.8
network: Created version ID: 1.7
network: Created version ID: 1.6
network: Created version ID: 1.5
network: Created version ID: 1.4
network: Created version ID: 1.3
basic: WARNING - specified JRE version, null is invalid platform version
basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@1c74402
basic: Saving session state to C:\Users\username\AppData\Local\Temp\session2717596495410700379
basic: Remote relaunch: LaunchJVMAppletMessage{appletID=1, conversationID=0, javaHome=C:\Program Files (x86)\Java\jre7, launchTime=81474922265, sendKill=false, [sun.plugin2.main.client.PluginMain, write_pipe_name=jpi2_pid7360_pipe5,read_pipe_name=jpi2_pid7360_pipe4]}
security:  --- parseCommandLine converted : -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
into:
[-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005]
security:  --- parseCommandLine converted : -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
into:
[-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005]
network: Created version ID: 2.0+
network: Created version ID: 1.6.0.10
basic: RemoteJVMLauncher.start(), pipe=Pipe{transport=WindowsNamedPipe: server: false; readPipe: jpi2_pid7360_pipe2, readBufferSz: 4096; writePipe: jpi2_pid7360_pipe3, writeBufferSz: 4096, initiatingSide=false} message: LaunchJVMAppletMessage{appletID=1, conversationID=0, javaHome=C:\Program Files (x86)\Java\jre7, launchTime=81474922265, sendKill=false, [sun.plugin2.main.client.PluginMain, write_pipe_name=jpi2_pid7360_pipe5,read_pipe_name=jpi2_pid7360_pipe4]}
basic: Thread[RemoteJVMLauncher-1,5,main] running...
basic: RemoteJVMLauncher.afterStart(): initializing streamers
handleLaunchJVM(): RemoteJVMLauncer.setCallBack for 1
handleLaunchJVM(): now unregisterApplet 1
basic: PluginMain.unregisterApplet: 1 from mananger sun.plugin2.applet.Applet2Manager@a55130
basic: Thread[RemoteJVMLauncher-1,5,main] completing: done=true exited=false
basic: Sending final message LaunchJVMAppletMessage{appletID=1, conversationID=0, process started=true, process exited=true, process exitedCode=0}

------------------

When JDWP properties are omitted from control panel, tail end of console has this output instead:

security: SSV validation: running: 1.7.0_40-ea, requested: null, range: null
network: Created version ID: 1.7.0.40
network: Created version ID: 1.7.0.40
security: continue with running version
network: Created version ID: 1.7.0.40.ea
network: Created version ID: 1.7
network: Created version ID: 2.2.40
security:  --- parseCommandLine converted :
into:
[]
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 116134 us, pluginInit dt 2860324 us, TotalTime: 2976458 us
ClockFrame.init
basic: Applet initialized
basic: Starting applet
basic: completed perf rollup
basic: Applet made visible
basic: Applet started
basic: Told clients applet is started
basic: Starting applet teardown
basic: Finished applet teardown
basic: PluginMain.unregisterApplet: 1 from mananger sun.plugin2.applet.Applet2Manager@19c705e
basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@87281f
basic: Applet supports legacy lifecycle model - add applet to lifecycle cache



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.Date;
import javax.swing.*;

public class ClockFrame extends JApplet
{
public void init()
{
System.out.println(  " ClockFrame.init "  );

final Thread t = new Thread(  " Init thread "  )
{
public void run()
{
frameUp();
}
};
t.start();
}

private void frameUp()
{
JFrame frame = new JFrame();
frame.setLayout( new BorderLayout() );
frame.setSize( 200, 170 );
frame.setLocation( 200, 200 );
final JLabel label = new JLabel();
label.setText( new Date().toString() );
new Thread( new Runnable() {
public void run()
{
while( true )
{
try
{
Thread.sleep( 1000 );
label.setText( new Date().toString() );
}
catch( Exception e )
{
// ignore
}
}
}
}).start();
frame.add( label, BorderLayout.CENTER );
frame.setVisible(true);
}
}

-------------------
HTML for launching applet:

<html>
<body>
<applet code= " ClockFrame "  codebase= " . "  height= " 100 "  width= " 150 "  name= " ClockFrame "  archive= " ClockFrame.jar " >
    <param name= " legacy_lifecycle "  value= " true " >
</applet>
</body>
</html>


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Remove JDWP properties from Java control panel, or don't browse off page hosting the original applet.
Comments
The problem here was that SEPARATE_JVM parameter was added to every relaunched applet. The patch replaces SEPARATE_JVM parameter (that was passed to relaunched applet to ensure that existing JVM instance is not used for relaunch) with a new one JCP_ARGS_REQUIRED, that indicates that relaunch should not happen in JVMs that were created without VM arguments specified in JCP (on Windows platform such JVM is any JVM that was not created during relaunch process). This new parameter allows to ensure that if relaunch was requested due to lack of JCP VM args then relaunch will not happen in the same JVM. On the other side it allows relaunched applet to reuse the existing JVM if it satisfies its needs, so multiple applets on the same page could be now re-launched in the same JVM even in JCP specifies some VM arguments.
05-01-2015

discussed in 08/20 - 7u40 triage and agreed to defer.
20-08-2013

SQE ok to defer from 7u40.
20-08-2013

defer request - this last worked in 7u17, so it's not a recent regression. Not a showstopper for 7u40 at this point in the release cycle.
20-08-2013