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

Casting Error - does not auto cast to Supplier when a lambda with no parameters is given

    Details

      Description

      FULL PRODUCT VERSION :
      java 8.0_151

      ADDITIONAL OS VERSION INFORMATION :
      ver Server 2012 R2

      A DESCRIPTION OF THE PROBLEM :
      if lambda expression was input to a Supplier without being cast, the error 'Internal compiler error: java.lang.UnsupportedOperationException: no glb for [public abstract class java.lang.Number' would occur.



      REGRESSION. Last worked in version 8u144

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a child method where it takes Supplier<O> as a parameter and input a lambda expression without a cast. I used a method where the parameter was Supplier<O>...

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      For the project to build/compile and not crash.
      ACTUAL -
      The error 'Internal compiler error: java.lang.UnsupportedOperationException: no glb for [public abstract class java.lang.Number' was thrown thus preventing the whole project from compiling.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Internal compiler error: java.lang.UnsupportedOperationException: no glb for [public abstract class java.lang.Number

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public < O > O run( Function< Foo, O > func ){
          if( func == null )
              return null;
          return firstNotNull( () -> func.apply( foo1 ),
                                         () -> func.apply( foo2 ) );
      }

      @SafeVarargs
      public static final < O > O firstNotNull( Supplier< O >... funcs ){
          for( Supplier< O > func : funcs ){
              O obj = func.get();
              if( obj != null )
                  return obj;
          }
          return null;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      return firstNotNull( (Supplier< O >) () -> func.apply( foo1 ),
                                     (Supplier< O >) () -> func.apply( foo2 ) );


        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: