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

Calling an applet method from a Html file in the IE Java plug-in

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
      and
      java version "1.4.2_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP
      Version 2002
      Service pack 1
      IE 6.0.2800

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Pentium P4m 1.9Ghz
      512 Ram

      A DESCRIPTION OF THE PROBLEM :
      I'm working on some Sun API (XMLEncoder) to obtain a Swing applet, and add some code for understanding the XMLEncoder.
      The calling method works fine when I call the method getDocument() direct from the applet, from the getDocument() applet button.
      But something goes wrong with writeObject when I call the method getDocument() from the html file?
      I think that this must be some bug with the Java Plug-in in IE because with Nescape or with Mozilla using 1.4.2_04 there is no problem...

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Some people and me write a simple applet to show the problem...to see step-by-step the bug process.
      1) Work great in IE:
      key pressed the applet's button "GET", calling the applet method:

      2) works for the html button: "String 22", calling the method
      --> public String getDocument(String obj)

      3) bug for the html button: "Integer 22 passed by script", calling the method:
      --> public String getDocument(Integer obj) (this is the same method that works great from an direct calling from the applet button "GET")

      3) bug for the html button: "Integer 22 hardcoded in applet", calling the method:
      --> public String getDocument()


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would like the same result for all calling situations:
      A right Object xml encoding:

      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
       <string>22</string>
      </java>
      ACTUAL -
      Results for case:
      1) String getDocument(Integer obj)
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
       <int>22</int>
      </java>

      2) <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
       <string>22</string>
      </java>

      3) ERROR BUG!!!!!!!!! Nothing is encode
      String getDocument(Integer obj)
      java.lang.NullPointerException
      Continuing ...
      java.lang.Exception: discarding statement XMLEncoder0.writeObject(Integer0);
      Continuing ...
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
      </java>

      4) ERROR BUG!!!!!!!!! Nothing is encode
      ava.lang.NullPointerException
      Continuing ...
      java.lang.Exception: discarding statement XMLEncoder0.writeObject(Integer0);
      Continuing ...
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
      </java>

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Results for case:
      I would like the same result as the 1) & 2) but:

      3) ERROR BUG!!!!!!!!! Nothing is encode
      String getDocument(Integer obj)
      java.lang.NullPointerException
      Continuing ...
      java.lang.Exception: discarding statement XMLEncoder0.writeObject(Integer0);
      Continuing ...
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
      </java>

      4) ERROR BUG!!!!!!!!! Nothing is encode
      ava.lang.NullPointerException
      Continuing ...
      java.lang.Exception: discarding statement XMLEncoder0.writeObject(Integer0);
      Continuing ...
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2_03" class="java.beans.XMLDecoder">
      </java>

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      the applet code:

      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;
      import javax.swing.*;
      import java.io.ByteArrayOutputStream;
      import java.io.BufferedOutputStream;

      public class Applethtml
          extends Applet {
        private boolean isStandalone = false;
        JPanel jPanel1 = new JPanel();
        BorderLayout borderLayout1 = new BorderLayout();
        JTextPane jTextPane1 = new JTextPane();
        JButton jButton = new JButton();
        public String getParameter(String key, String def) {
          return isStandalone ? System.getProperty(key, def) :
              (getParameter(key) != null ? getParameter(key) : def);
        }

        public Applethtml() {}

        public void init() {
          try {
            jbInit();
          }
          catch (Exception e) {
            e.printStackTrace();
          }
        }

        private void jbInit() throws Exception {
          jPanel1.setLayout(borderLayout1);
          jTextPane1.setText("Exemple");
          jButton.setText("Get");
          jButton.addKeyListener(new Applethtml_jButton_keyAdapter(this));
          this.addMouseListener(new Applethtml_this_mouseAdapter(this));
          this.addMouseListener(new Applethtml_this_mouseAdapter
                                (this));
          this.add(jPanel1, null);
          this.add(jTextPane1, null);
          this.add(jButton, null);
        }

        public void start() {}

        public void stop() {}

        public void destroy() {}

        public String getAppletInfo() {
          return "Information applet";
        }

        public String[][] getParameterInfo() {
          return null;
        }

        public String getDocument(String obj) {
          String enc = encode( (Object) obj);
          System.out.println(enc);
          return enc;
        }

        public String getDocument(Integer obj) {
          System.out.println("String getDocument(Integer obj)");
          String enc = encode( (Object) obj);
          System.out.println(enc);
          return enc;
        }

        public String getDocument() {
          Integer obj = new Integer(22);
          System.out.println( (Object) obj);
          String enc = encode( (Object) obj);
          System.out.println(enc);
          return enc;
        }

        private String encode(Object obj) {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          baos.reset();
          java.beans.XMLEncoder xmlencoder = new java.beans.XMLEncoder(new
              BufferedOutputStream(baos));
          xmlencoder.writeObject(obj);
          xmlencoder.close();
          return
              baos.toString();
        }

        String jButton_keyPressed(KeyEvent e) {
          String codeRetour = (String) getDocument(new Integer(22));
          System.out.println("RESULT: " + codeRetour);
          return codeRetour;
        }

        String this_mouseClicked(MouseEvent e) {
          String codeRetour = (String) getDocument(new Integer(33));
          System.out.println("RESULT: " + codeRetour);
          return codeRetour;
        }
      }

      class Applethtml_jButton_keyAdapter
          extends java.awt.event.KeyAdapter {
        Applethtml adaptee;
        Applethtml_jButton_keyAdapter(Applethtml adaptee) {
          this.adaptee = adaptee;
        }

        public void keyPressed(KeyEvent e) {
          adaptee.jButton_keyPressed(e);
        }
      }

      class Applethtml_this_mouseAdapter
          extends java.awt.event.MouseAdapter {
        Applethtml adaptee;
        Applethtml_this_mouseAdapter(Applethtml adaptee) {
          this.adaptee = adaptee;
        }

        public void mouseClicked(MouseEvent e) {
          adaptee.this_mouseClicked(e);
        }
      }

      ----------------------------------------------------------------------------------------------------
      htmlfile:

      <html>
        <head>
          <title> test_HTML</title>
          </head>
          <body>Exemple test<br>
            <applet codebase = "."
              code = "Applethtml.class"
      archive="Applethtml.jar"
              name = "AppletTest"
              width = "400"
              height = "300"
              hspace = "0"
              vspace = "0"
              align = "middle">
              </applet>
              <BR>
                <input type="button"
                  value="String 22"
                  onClick="alert(AppletTest.getDocument('22'))">
                  <input type="button"
                    value="Integer 22 passed by script"
                    onClick="alert(AppletTest.getDocument(22))">
                    <input type="button"
                      value="Integer 22 hardcoded in applet"
                      onClick="alert(AppletTest.getDocument())">
                      </body>
                      </html>



      ---------- END SOURCE ----------
      ###@###.### 2004-12-06 21:12:47 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              malenkov Sergey Malenkov (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: