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

wrong effectively final determination by javac

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 20
    • 19
    • tools
    • b22

      File: Demo.java


      public class Demo {
          public static void main(String[] args) {
              for (int i = 0; i < 10; i++) {
                  Runnable r = () -> System.out.println(i);
                  r.run();
                  break;
              }
          }
      }

      Expected: compilation failure (as "i" is not effectively final)
      Observed: javac compiles without error.

      Source: compiler-dev email

      https://mail.openjdk.org/pipermail/compiler-dev/2022-September/020481.html

            acobbs Archie Cobbs
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: