JDK-8294461 : wrong effectively final determination by javac
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-09-27
  • Updated: 2022-12-29
  • Resolved: 2022-10-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 b22Fixed
Related Reports
CSR :  
Relates :  
Relates :  
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

Comments
Changeset: b8ad6cd9 Author: Archie L. Cobbs <archie.cobbs@gmail.com> Committer: Vicente Romero <vromero@openjdk.org> Date: 2022-10-27 15:58:46 +0000 URL: https://git.openjdk.org/jdk/commit/b8ad6cd98a7e4b577b888dc5f9d93c2e4d3bf177
27-10-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10856 Date: 2022-10-25 15:36:05 +0000
25-10-2022

could be related to JDK-8043179
27-09-2022

Same behaviour seen in jdk 18, 17, 11.0.9 and 8 (1.8.0_241) as well (versions I tested)
27-09-2022