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

A number passed from JavaScript to Applet become an invalid number format

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b33
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      JRE 1.6.0_10-rc

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

      A DESCRIPTION OF THE PROBLEM :
      We have an method in applet that process a number passed from JavaScript. It worked fine in previous version of JRE but has java.lang.NumberFormatException in JRE 1.6.0_10-RC

      We found that a number 1219224288742 in JavaScript becomes 1.219224288742E12 in our Applet. When we parse it into Long, it has error.

      This is not the case in previous version of JRE including 1.6.0_7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Prepare and compile a Java Applet as follows,

      import java.applet.Applet;

      public class TestApplet extends Applet {
        public void init() {
          ;
        }

        public void destroy() {
      ;
        }

        public void printStringValue(String strValue) {
          System.out.println("strValue: [" + strValue + "]");
        }
      }

      2. Prepare a HTML as follows,
      <html><head><title>ABC</title></head>
      <applet code="TestApplet.class" name="test" width="1" height="1"></applet>
      <script language="JavaScript">
      <!--
      var m_currTime = null;
      m_currTime = new Date().getTime();
      alert("m_currTime: " + m_currTime);

      test.printStringValue(m_currTime);
      //-->
      </script>
      <body>
      TEST
      </body>
      </html>

      3. Run the HTML in web browser


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The number display in the Java Console should has the same format as that prompted in JavaScript.

      e.g.:
      strValue: [1219224288742]


      ACTUAL -
      The number display in the Java Console has different format as that prompted in JavaScript.

      e.g.:
      strValue: [1.219224086554E12]


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The number format is wrong and induces problem if we further process the value.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      TestApplet.java

      import java.applet.Applet;

      public class TestApplet extends Applet {
        public void init() {
          ;
        }

        public void destroy() {
      ;
        }

        public void printStringValue(String strValue) {
          System.out.println("strValue: [" + strValue + "]");
        }
      }

      =================

      testApplet.html

      <html><head><title>ABC</title></head>
      <applet code="TestApplet.class" name="test" width="1" height="1"></applet>
      <script language="JavaScript">
      <!--
      var m_currTime = null;
      m_currTime = new Date().getTime();
      alert("m_currTime: " + m_currTime);

      test.printStringValue(m_currTime);
      //-->
      </script>
      <body>
      TEST
      </body>
      </html>



      ---------- END SOURCE ----------

      Release Regression From : 6u7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hdongorcl Hao Dong (Inactive)
                Reporter:
                ndcosta Nelson Dcosta
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: