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

Error.stack needs trimming

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • None
    • core-libs
    • None
    • b94
    • Verified

    Description

      Error.stack in other JavaScript engines is usually a string, and has different contents. To help embedders switching from other JavaScript engines, nashorn should present Error.stack in a compatible way. Consider the following -

      function error() {
        try {
          throw new Error('foo');
        } catch (e) {
          var s = e.stack;
          print(typeof s + ' ' + Array.isArray(s));
          print(s);
        }
      }
      error();

      when run with v8, this prints -

      string false
      Error: foo
          at error (error.js:3:11)
          at error.js:11:1

      when run with spidermonkey, this prints -

      string false
      error@error.js:3
      @error.js:11

      when run with nashorn, this prints -

      object true
      jdk.nashorn.internal.scripts.Script$error.error(error.js:3),jdk.nashorn.internal.scripts.Script$error.runScript(error.js:11)

      The 'jdk.nashorn.internal.scripts.Script$error' is unnecessary and should be removed. runScript is also internal and should be removed. The array should be converted to a String.

      Attachments

        Activity

          People

            sundar Sundararajan Athijegannathan
            akhil Akhil Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: