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

Compiler issue with IntConsumer returns Function.identity().apply()

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      declaring an IntConsumer like this:

              int z;
              IntConsumer iConsumer = (a) -> z;

      gives a compilation error: "Void methods cannot return a value". Ok

      But like this :

              int z;
              IntConsumer iConsumer = (a) -> Function.identity().apply(z);

      When Function.identity().apply(z) returns an Object, no compilation error here.

      Shouldn't also give a compilation error?


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please check code sample

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation error
      ACTUAL -
      No compilation error

      ---------- BEGIN SOURCE ----------
      int z;
      IntConsumer iConsumer = (a) -> Function.identity().apply(z);
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            fmatte Fairoz Matte
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: