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

javac, some lambda programs are rejected by flow analysis

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b115
    • Verification:
      Verified

      Description

      This compiles

      public class Tmp
      {
          final Runnable r1 = ()->System.out.println(r1);
      }

      This does NOT . . . . . . . . . . . . . . . . . . . . . . . . .

      public class Tmp
      {
          final Runnable r1;

          final Runnable r2 = ()-> System.out.println(r1); // Error: r1 not
      initialized

          Tmp()
          {
              r1 = ()->System.out.println(r1); // Error: r1 not initialized
          }
      }

      This compiles . . . . . . . . . . . . . . . . . . . . . . . . .

      public class Tmp
      {
          final Object lock = new Object();

          final Runnable r2 = ()->{
              System.out.println(r2);
              synchronized (lock){
              }
          };
      }

      This does NOT . . . . . . . . . . . . . . . . . . . . . . . . .

      public class Tmp
      {
          final Object lock = new Object();

          final Runnable r2 = ()->{
              synchronized (lock){
                  System.out.println(r2); // Error: self-reference in initializer
              }
          };
      }


      reported by Zhong Yu in lambda-dev list.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              vromero Vicente Arturo Romero Zaldivar
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: