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

Missing checkcast in void-returning lambda

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 11, 12, 13
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Introduced In Version:
      11

      Description

      Recent versions of javac no longer emit a checkcast in the body of the lambda expression below, which seems like a regression.

      This was introduced by the fix for JDK-8203338:
      http://hg.openjdk.java.net/jdk/jdk/rev/e0eca40cd514
      https://bugs.openjdk.java.net/browse/JDK-8203338

      ```
      abstract class T {

        interface I<X> {
          X d();
        }

        abstract <X> I<X> c();

        void f() {
          Runnable r = () -> this.<Long>c().d();
        }
      }
      ```

      with javac full version "10.0.2+13"

        private void lambda$f$0();
          descriptor: ()V
          flags: (0x1002) ACC_PRIVATE, ACC_SYNTHETIC
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokevirtual #3 // Method c:()LT$I;
               4: invokeinterface #4, 1 // InterfaceMethod T$I.d:()Ljava/lang/Object;
               9: checkcast #5 // class java/lang/Long
              12: pop
              13: return
            LineNumberTable:
              line 10: 0

      with javac full version "11.0.2+9" (and newer):

        private void lambda$f$0();
          descriptor: ()V
          flags: (0x1002) ACC_PRIVATE, ACC_SYNTHETIC
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokevirtual #3 // Method c:()LT$I;
               4: invokeinterface #4, 1 // InterfaceMethod T$I.d:()Ljava/lang/Object;
               9: pop
              10: return
            LineNumberTable:
              line 10: 0

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bsrbnd Bernard Blaser
                Reporter:
                cushon Liam Miller-Cushon
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: