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

Passing Java Objects to JavaScript crashes the Browser in plug-in 1.4.0 Beta 3.

XMLWordPrintable

    • 05
    • x86
    • windows_nt, windows_2000



        Name: gm110360 Date: 12/12/2001


        java version "1.4.0 Beta 3"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0 Beta 3)
        Java HotSpot(TM) Client VM (build 1.4.0 Beta 3, mixed mode)

        STEPS TO REPRODUCE THE PROBLEM
        ==============================
        1.On loading of Applet, a java Object is passed to JavaScript
        2.If the JavaScript invokes a method in this Java Object to get a non-string
        object.
        3.The browser crashes.(In plug-in 1.4.0 Beta 3).

        SOURCE CODE
        ===========
        *****************Person.java****************
        public class Person{

        public String getStatus(){
        return "Success";
        }

        }
        ******************TestApplet.java*************
        import netscape.javascript.JSObject;
        import java.lang.*;
        import java.applet.*;
        import java.awt.Graphics;

        public class TestApplet extends Applet{

        JSObject win;

        public void start(){
                        win = JSObject.getWindow(this);
                        Object t[] = new Object[1];
                        t[0] = new UserObject("test1");
                        win.call("callJava", t);
                 }

        }
        ************UserObject.java****************
        public class UserObject {
        private String name;

        public UserObject(String name) {
        this.name=name;
        }

        public String getName(){
        return name;
        }


        public Object getObj(){
        Object obj= new Person();
        return obj;
        }

        }
        *************person.htm********************
        <html>
        <head>
        <script>


        function callJava(javaObj)
        {
        var var2 = javaObj.getName();


                var var1 = javaObj.getObj();

                
                var var3 = var1.getStatus();

        document.forms[0].name1.value = var3;
        }

        </script>
        </head>

        <body>
        <center>


        <!-- Uncomment the following tag for loading the Applet in IE without Plugin
         <Applet code="Person.class" MAYSCRIPT name="array"></Applet>-->



        <!-- Uncomment the following tag for loading the Applet in IE with Plugin-->
         <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                id="array" WIDTH=190 HEIGHT=190 codebase="." name="array">
        <PARAM NAME=CODE VALUE="TestApplet.class">
        <PARAM NAME=SCRIPTABLE VALUE=TRUE>
        <PARAM NAME=MAYSCRIPT VALUE=TRUE>
        </OBJECT>


        <form>
        <input type=text value="" name = "name1" size = 30 >
        </form>

        </body>
        </center>

        </html>
        (Review ID: 137243)
        ======================================================================

              djayaramsunw Devananda Jayaraman (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: