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

Applet is freezed when JSObject.getWindow()/call() is used with a large amount of string data

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      windows_vista
    • Verification:
      Not verified

      Description

      When string object with the size of about 5 M-bytes is submitted, Applet is freezed with such a "JVM heartbeat .. dead, send ts: 6323053543, now ts: 6333053288, dT 9999745" message.

      - STEPS TO FOLLOW TO REPRODUCE THE PROBLEM:

      OS: Windows XP SP2
      Browser: IE6/IE7
      JRE: 6u10/6u11

      1. Make "test" directory and change the directory
      2. Save the following codes
      3. Compile the following java code (with -classpath "C:\Program Files\Java\jdk1.6.0_10\jre\lib\plugin.jar")
      4. Create TestApplet.jar with test\TestApplet$1.class and test\TestApplet.class
      5. Run the following HTML code
      6. Input "5" as the data size in Applet


      - EXPECTED VERSUS ACTUAL BEHAVIOR:

      EXPECTED:

      Such a "JVM heartbeat" message does not appear like JRE 6u07.

      ACTUAL:

      When string object with the size of about 5 M-bytes is submitted, Applet is freezed with such a "JVM heartbeat .. dead, send ts: 6323053543, now ts: 6333053288, dT 9999745" message.

      OUTPUT (Java Console) xxx: Japanese
      ----------------------------------------------------------------------------
      basic: xxxxxxxxxxxxxxxxxxxxxxxxxx: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@152544e
      basic: xxxxxxxxxxxxxxxxxxxxxx
      basic: Applet resized and added to parent container
      basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 689351 us, pluginInit dt 2999658 us, TotalTime: 3689009 us
      basic: Applet initialized
      basic: xxxxxxxxxxxxxxxxxxxxxxxxxx: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@152544e
      basic: Applet made visible
      basic: Starting applet
      basic: Applet started
      basic: Told clients applet is started
      Write size : 5242880 byte
      Start : Thu Dec 18 22:56:32 JST 2008
      JVM heartbeat .. dead, send ts: 48285414798, now ts: 48295408592, dT 9993794
      ----------------------------------------------------------------------------

      For the following source code, "JVM heartbeat" message is always displayed when the value of 5M or more is input, while Java Plug-in 2 is available.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.*;
      import java.awt.event.*;
      import java.util.Date;
      import javax.swing.*;

      import netscape.javascript.JSObject;

      public class TestApplet extends JApplet {

        int size = 1;
        JTextField inpText=new JTextField(2);
        private static final long serialVersionUID = 1L;
        public TestApplet() throws HeadlessException {
        }
        
        public void init() {
          JPanel p1=new JPanel();
          p1.setBackground(new Color(0xFFFFFF));
          this.getContentPane().add(p1);
          inpText.setText(String.valueOf(size));
          JButton btn=new JButton("exe");
          btn.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e){
                  execute();
              }
          });
          p1.add(new JTextArea("size : "));
          p1.add(inpText);
          p1.add(new JTextArea("M "));
          p1.add(btn);

        }

        public void execute() {
              JSObject win = JSObject.getWindow(this);
              int sizeWrite = Integer.valueOf(inpText.getText()).intValue();

              size = sizeWrite * 1048576;
              StringBuffer stringBuffer = new StringBuffer(size);
              for (int i1 = 0; i1 < size; i1++) {
                stringBuffer.append('a');
              }
              System.out.println("Write size : " + size +" byte");
              System.out.println("Start : " + new Date());
              win.call("setResultXml", new Object[]{stringBuffer.toString()});
              System.out.println("Done : " + new Date());
        }
      }
      ---------- END SOURCE ------------

      ---------- BEGIN HTML-SOURCE ----------
      <HTML>

      <HEAD>

      <SCRIPT type="text/javascript">
      function setResultXml(resultXml) {
      }
      </SCRIPT>

      </HEAD>

      <BODY>

      <h1>LiveConnect Write Test</h1>

      <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
           width="200" height="100" align="baseline">
           <PARAM NAME="code" VALUE="test.TestApplet.class">
           <PARAM NAME="codebase" VALUE=".">
           <PARAM NAME="type" VALUE="application/x-java-applet">
           <PARAM NAME="archive" VALUE="TestApplet.jar">
           <PARAM NAME="MAYSCRIPT" VALUE="true">
              No JRE support for APPLET !
      </OBJECT>
      <FORM name="testForm">
        <INPUT type="hidden" name="testItem">
      </FORM>

      </BODY>
      </HTML>
      ---------- END HTML-SOURCE ------------

      Bug WorkaroundWhen Java Plug-in 2 option is not checked, the above test program works normally.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kbr Kenneth Russell (Inactive)
                Reporter:
                xiaojuzh Xiaojun Zhang (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: