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

arguments are handled differently in apply for JS functions and AbstractJSObjects

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 9
    • 9
    • core-libs
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: