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

Cannot call applet method with array argument from Javascript

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0
    • deploy
    • b42
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
      Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)

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

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Java(TM) Plug-in: Version 1.4.2_07
      Using JRE version 1.4.2_07 Java HotSpot(TM) Client VM

      MSIE Version 6.0.2900.2180.xpsp_sp2_rtm.040803-2158

      A DESCRIPTION OF THE PROBLEM :
      Retrieve an array from one applet and via Javascript use the array as an argument to a public method in another applet running in another page does not work. It works fine when the type of the array is java.lang.String, so I imagine primitive types work also. However, when use an array with a type which is proprietary to our applet, it cannot find the method in the Applet class and I get an exception in the Java console. I tested this with the Mozilla browser and it works fine in Mozilla with the same Java plug-in.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open the test.html file outlined below ensuring that the classes are in the classpath. Also, pop-ups and active content must not be blocked.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected the method to get called which would produce output in the Java console indicating it was called.
      ACTUAL -
      testMethod called

      testMethod called with testString

      java.lang.Exception: setTestArray{0} :no such method exists


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.Exception: setTestArray{0} :no such method exists

      at sun.plugin.com.JavaClass.getMethod1(Unknown Source)

      at sun.plugin.com.JavaClass.getDispatcher(Unknown Source)

      at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)

      at sun.plugin.com.DispatchImpl$1.run(Unknown Source)

      at java.security.AccessController.doPrivileged(Native Method)

      at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

      java.lang.Exception: java.lang.Exception: setTestArray{0} :no such method exists

      at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)

      at sun.plugin.com.DispatchImpl$1.run(Unknown Source)

      at java.security.AccessController.doPrivileged(Native Method)

      at sun.plugin.com.DispatchImpl.invoke(Unknown Source)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // TestApplet1.java
      package com.accucast4.gui;
      import javax.swing.JApplet;
      import com.accucast4.template.MimeMessageFacade;

      public class TestApplet1 extends JApplet {
          private MimeMessageFacade[] testArray;
          public void init() {
              testArray = new MimeMessageFacade[] { };
          }
          public MimeMessageFacade[] getTestArray() {
              return testArray;
          }
      }

      // TestApplet2.java
      package com.accucast4.gui;
      import javax.swing.JApplet;

      import com.accucast4.template.MimeMessageFacade;

      public class TestApplet2 extends JApplet {
          private MimeMessageFacade[] testArray;

          public void testMethod() {
              System.out.println("testMethod called");
          }
          public void testMethod(String testString) {
              System.out.println("testMethod called with " + testString);
          }
          public void setTestArray(MimeMessageFacade[] testArray) {
              System.out.println("setTestArray called");
              this.testArray = testArray;
          }
      }

      // MimeMessageFacade.java
      package com.accucast4.template;

      public class MimeMessageFacade implements Serializable {
      }

      // test.html
      <html><head>
      <script type="text/javascript" language="Javascript">
      function onLoad() {
      window.open("test2.html", "test2");
      }
      function getArray() {
      return applet1.getTestArray();
      }
      </script></head>
      <body onload="onLoad()">
      <APPLET CODE="com.accucast4.gui.TestApplet1.class"
              WIDTH="100" HEIGHT="100" NAME="applet1" ID="applet1" MAYSCRIPT>
      </body>
      </html>

      //test2.html
      <html><head>
      <script type="text/javascript" language="Javascript">
      function onLoad() {
       applet2.testMethod();
       applet2.testMethod("testString");
       var parent = window.opener;
       if(parent)
         if(parent.open && !parent.closed)
           if(parent.document)
             if(parent.document.applet1)
               applet2.setTestArray(parent.getArray());
      }
      </script></head>
      <body onload="onLoad()">
      <APPLET CODE="com.accucast4.gui.TestApplet2.class"
              WIDTH="100"
      HEIGHT="100"
      NAME="applet2"
      ID="applet2"
      MAYSCRIPT>
      </body>
      </html>
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround found, although this exact code works with Mozilla.
      ###@###.### 2005-04-20 23:11:16 GMT

            jchusunw Jacky Chu (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: