wrong effectively final determination by javac

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 20
    • Affects Version/s: 19
    • Component/s: 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

            Assignee:
            Archie Cobbs
            Reporter:
            Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: