Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7133324

REGRESSION:Multiple applets on same page often result in multiple java processes starting

    Details

    • Subcomponent:
    • Introduced In Version:
      7u4
    • CPU:
      x86
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      Java Plug-in 10.4.0.8
      Using JRE version 1.7.0_04-ea-b08 Java HotSpot(TM) Client VM

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Ultimate x64 (Version 6.1.7601). Windows was running as a virtual machine.

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Occurs in Firefox 9.0.1, Chrome 16.0.912.77, have not seen problem occur in IE 9.

      A DESCRIPTION OF THE PROBLEM :
      If multiple applets (either different applets or the same applet multiple times) are on the same HTML page, when Java starts you will often get multiple java.exe processes, along with multiple Java consoles. When this happens, applets may be running in different VM instances and will have separate AppletContexts and be unable to see or communicate with the other applets. In addition, if a JavaScript wishes to interact with one of the applets, it may be unable to do so if the script and the applet are not running in the same context.

      According to the docs for the AppletContext class, the AppletContext should correspond to the document containing the applet and the other applets in the same document.

      REGRESSION. Last worked in version 6u29

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a test applet that pauses a few seconds, then calls AppletContext.getAppelts to discover the other applets in the same context. Create an HTML page containing two instances of the same test applet. Load page in Firefox and both applets will load, pause, then enumerate the other applets in the AppletContext.

      For added fun, add a button and some JavaScript to the HTML page that calls a public method in the test applet to do the same enumeration of all applets.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Getting the AppletContext and enumerating the applets available to the test applet should always result in a list of both applets on the page. Likewise, the JavaScript should be able to access both test applets on the same page.
      ACTUAL -
      About 40-50% of the time in Firefox or Chrome, two Java processes will start and two separate Java consoles will come up, and each test applet will load in a different process and output messages to a different console. When this happens, each applet is isolated from the other and is unable to see the other when calling AppletContext.getApplets.

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      Test applet source:

      import java.applet.Applet;
      import java.applet.AppletContext;
      import java.util.Enumeration;

      public class BasicApplet extends Applet
      {
      private String mName;

      public void init()
      {
      mName = getParameter("name");
      System.out.println("BasicApplet.init: " + mName );
      }

      public void start()
      {
      System.out.println("BasicApplet.start: " + mName );
      new Thread( new Runnable() {
      public void run() {
      try {
      Thread.sleep(5000);
      listKnownApplets();
      } catch ( Exception e ) {
      // ignore
      }
      }
      } ).start();
      }

      public void listKnownApplets()
      {
      int count = 0;
      AppletContext ctxt = getAppletContext();
      Enumeration e = ctxt.getApplets();
      while ( e.hasMoreElements() )
      {
      count++;
      Applet a = (Applet)e.nextElement();
      if ( !this.equals( a ) )
      {
      System.out.println( "BasicApplet [" + mName + "] found another applet: " + a.getParameter("name") );
      }
      }
      if ( count <= 1 )
      {
      System.out.println("BasicApplet [" + mName + "] did not find any applets other than itself." );
      }
      }
      }

      ===
      HTML for running above:

      <html>
      <head>
      <script language="JavaScript" type="text/javascript">
      <!--
      function listothers() {
      if ( document.Applet_1 ) {
      document.Applet_1.listKnownApplets();
      }
      else {
      alert( "Applet_1 not found!" );
      }
      if ( document.Applet_2 ) {
      document.Applet_2.listKnownApplets();
      }
      else {
      alert( "Applet_2 not found!" );
      }
      }
      //-->
      </script>
      </head>
      <body>
      <div id="appletdiv">
      <applet name="Applet_1" code="BasicApplet"
      codebase="." height="0" width="0">
      </applet>
      <p>
      <applet name="Applet_2" code="BasicApplet"
      codebase="." height="0" width="0">
      </applet>
      </div>
      <p>
      <form>
      <input type="button" name="List other applets" value="List Other Applets" onclick="listothers()">
      </form>
      </body>
      </html>
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              nam Nam Nguyen (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: