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

arguments are handled differently in apply for JS functions and AbstractJSObjects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • core-libs
    • None

        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

          1. Main.java
            0.9 kB
            Michael Haupt

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

                Created:
                Updated:
                Resolved: