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

arguments are handled differently in apply for JS functions and AbstractJSObjects

    XMLWordPrintable

    Details

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

      Backports

        Description

        Functions defined at JS level and functions defined as an AbstractJSObject are passed arguments differently when invoked through Function.prototype.apply.call(): the AbstractJSObject implementation will be passed an Object[] containing an Object[] holding all the arguments, whereas the JS function will be passed an array containing the arguments (not nested in an extra array).

        The attached test case produces the following output:
        args = [1, 2, 3]
        args = [[1, 2, 3]] // note this line
        1
        2
        3
        1
        2
        3

        Expected:
        args = [1, 2, 3]
        args = [1, 2, 3] // this differs from above
        1
        2
        3
        1
        2
        3

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mhaupt Michael Haupt
                Reporter:
                mhaupt Michael Haupt
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: