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

wrong effectively final determination by javac

    XMLWordPrintable

Details

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

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: