-
Bug
-
Resolution: Fixed
-
P3
-
19
-
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
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
- csr for
-
JDK-8296148 wrong effectively final determination by javac
-
- Closed
-
- relates to
-
JDK-8043179 Lambda expression can mutate final field
-
- Resolved
-
-
JDK-8299849 Revert JDK-8294461: wrong effectively final determination by javac
-
- Closed
-
-
JDK-8299416 javac complains about "local variables referenced from an inner class must be final or effectively final" although variable is only assigned once
-
- Open
-
-
JDK-8299861 Inconsistent handling of effectively final and blank final variables
-
- Open
-
(2 links to)