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

Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None

      Backports

        Description

        function func(arg) {
          (function() { print(eval('this')); }).call(arg);
        }

        func(this);
        func({});
        func({ toString: function() "foo" });
        func(new java.lang.Vector());

        Expected:

        [object global]
        [object Object]
        foo
        []

        Last one is toString value on empty Vector instance


        Actual output:

        [object global]
        [object Object]
        foo
        [object global]

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  sundar Sundararajan Athijegannathan
                  Reporter:
                  sundar Sundararajan Athijegannathan
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: