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

Varargs argument lost when called

XMLWordPrintable

    • 9
    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+173)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+173, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OSX Sierra 10.12.5

      A DESCRIPTION OF THE PROBLEM :
      The first parameter of the varargs call is being lost. It seems to only occur when the varargs type is the same type as the class it is in.

      REGRESSION. Last worked in version 8u131

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_131"
      Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should output 2
      ACTUAL -
      Outputs 1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.function.BiFunction;

      public class Bob {
        private static int varArgs(Bob... bobs) {
          return bobs.length;
        }

        private static int runBiFunction(BiFunction<Bob, Bob, Integer> conv, Bob bob1, Bob bob2) {
          return conv.apply(bob1, bob2);
        }

        public static void main(String[] args) {
          System.out.println(runBiFunction(Bob::varArgs, new Bob(), new Bob()));
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Move varArgs to a separate class.

            sadayapalam Srikanth Adayapalam (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: