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

Throwing object with error prototype causes error proto to be caught

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b39
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        The code to use the existing exception in ECMAException.create will use an inherited nashornException property, causing catch clauses to be executed with the prototype object instead of the actual thrown object.

        Code to reproduce:

        function CustomError() {}
        CustomError.prototype = new Error();

        var c = new CustomError();

        try {
            throw c;
        } catch (e) {
            print(e === c);
            print(e === CustomError.prototype);
        }

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                hannesw Hannes Wallnoefer
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: