United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6835450 java.applet.AppletContext.showDocument(URL, String) does not work with 1.6.0_13
JDK-6835450 : java.applet.AppletContext.showDocument(URL, String) does not work with 1.6.0_13

Details
Type:
Bug
Submit Date:
2009-04-29
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-10-28
Component:
deploy
OS:
windows_xp,windows
Sub-Component:
webstart
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6,6u16
Fixed Versions:
6u18 (b04)

Related Reports
Backport:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versione 5.1.2600]

Microsoft Windows [Version 5.2.3790]

Linux ws-devel8 2.6.27-11-generic #1 SMP Wed Apr 1 20:57:48 UTC 2009 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
With Java 1.6.0_13 if you have an applet run through Java Web Start and you call:

getAppletContext().showDocument(myURL, "_blank");

the browser is not launched and the URL is not opened.
This problem sometimes happens with 1.6.0_12, too, although we have an applet in which this works correctly in 1.6.0_12, but does not work in 1.6.0_13.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. compile the attached code
2. create a JAR and sign it
3. create the following JNLP and put it into a web server, together with the JAR, adapting the codebase and jar href attributes values as appropriate:

<jnlp spec="1.5+" codebase="http://localhost:8080/test/" version="1.0">
  <information>
    <title>Test</title>
    <vendor>Test</vendor>
    <homepage href="http://www.sun.com"/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <update check="timeout" policy="always"/>
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6.0_13"/>
    <j2se version="1.6"/>
    <j2se version="1.5"/>
    <jar href="http://localhost:8080/test/test.jar" download="eager" main="false"/>
  </resources>
  <applet-desc name="Test" main-class="test.MyApplet" width="400" height="200">
  </applet-desc>
</jnlp>

4. connect to that jnlp using any browser
5. after the application has started, click on the "click" button

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A new browser page is opened, pointing to http://www.sun.com

This happens correctly if you have any of the following tested Java version installed:

1.5.0_17
1.6.0_01
1.6.0_03
1.6.0_05
1.6.0_10
ACTUAL -
Nothing happens.

This is always reproducible with 1.6.0_13.

The attached test case reproduces the problem also with 1.6.0_12. However, we have a production applet in which the described method works correctly with 1.6.0_12, but does not work with 1.6.0_13.

The problem has been reproduced under Windows XP, Windows XP x64 Edition and Linux Ubuntu 8.10.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages are given. No exceptions are thrown.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class MyApplet extends JApplet
{

	@Override
	public void init()
	{
		SwingUtilities.invokeLater(new Runnable()
			{
				public void run()
				{
					JPanel p = new JPanel();
					JButton b = new JButton("click");
					b.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								try
								{
									getAppletContext()
									  .showDocument(
									  new URL("http://www.sun.com"),
									  "_blank");
								}
								catch(Exception e1)
								{
									throw new RuntimeException(e1);
								}
							}
						});
					p.add(b);
					add(p);
				}
			});
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Uninstall JRE 1.6.0_13.

SUPPORT :
YES

Release Regression From : 6u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

For this particular scenario, when an applet is started through the applet-desc from a JNLP file, the AppletExecutionContext is set to NoopExecutionContext. Currently, the showDocument method does nothing in NoopExecutionContext.
A potential fix is to implement showDocument in NoopExecutionContext to be the same as the one in DisconnectedExecutionContext, i.e. using the one in the Config class because in the scenario, the applet isn't running inside the browser.
                                     
2009-10-10
EVALUATION

showDocument doesn't work if an applet is running outside of the browser in the following scenarios:
1. via the applet-desc JNLP tag.
2. relaunched from the desktop after a draggable JNLP applet has been dragged outside the browser.

A simple fix is in JNLP2Viewer:
    when setting the applet execution context, creating the DisconnectedExceutionContext instead of NoopExecutionContext.
                                     
2009-10-15



Hardware and Software, Engineered to Work Together