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

Nashorn reports NaN for undefined

XMLWordPrintable

    • b17
    • 9
    • b06
    • x86_64
    • linux_ubuntu

      A DESCRIPTION OF THE PROBLEM :
      #Version: jdk-12.0.1, jdk-11.0.3

      #Testcase:
      1. var NISLFuzzingFunc = function (target_test, target) {
      2. print(target_test[0][0]) //undefined
      3. target_test = target_test[0];
      4. print(target_test[0]); //NaN
      5. print("==================================");
      6. print(target[0][0]); //undefined
      7. target = target[0];
      8. print(target[0]); //undefined
      9. };
      10. var NISLParameter0 = [62303, 0.8726223721680498];
      11. var NISLParameter1 = [62303];
      12. NISLFuzzingFunc(NISLParameter0, NISLParameter1);

      #Command:
      ./nashorn/jdk-12.0.1/bin/jjs --no-syntax-extensions=true --no-deprecation-warning=true testcase.js

      #Output:
      undefined
      NaN
      ==================================
      undefined
      undefined

      #Expected output:
      undefined
      undefined
      ==================================
      undefined
      undefined

      #Description:
          For the above testcase, the output of Line 4 should be consistent with the output of Line 2, and should be "undefined", but the output of Line 4 is "NaN". We try to delve into the reasons, if the elements of the array do not contain a decimal(such as NISLParameter1), the output of Line 8 is the normal value "undefined". When there is a decimal in the array (NISLParameter0), the output of the 4th Line will be abnormal.
         Is this a bug of Nashorn? Looking forward to your reply.


            hannesw Hannes Wallnoefer
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: