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

Function.prototype.apply interacts incorrectly with 'arguments'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 8u60, 9
    • core-libs
    • b81
    • x86
    • os_x

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_60"
        Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
        Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin c056.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        The following code incorrectly produces `4` in Nashorn (it should produce `2`):

        (function(f){
          return function(a1, a2, a3, a4){
            return f.apply(this, arguments);
          }
        })
        (function(){
          return arguments.length;
        })
        (1, 2);

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Observe that the code provided in the description produces an incorrect result when run through Nashorn.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        2, the number of arguments with which the function is called.
        ACTUAL -
        4, the number of formal parameters of the function.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

                sundar Sundararajan Athijegannathan
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: