RFR: 8043179: Lambda expression can mutate final field [v4]
Archie L. Cobbs
duke at openjdk.org
Wed Sep 28 16:45:10 UTC 2022
> This patch causes lambdas to be treated like non-constructor methods with respect to field initialization in `Flow.AssignAnalyzer`.
>
> This fixes [JDK-8043179](https://bugs.openjdk.org/browse/JDK-8043179); the test program in the bug now gives this:
>
> LambdaFieldInit.java:6: error: variable x might already have been assigned
> Runnable r1 = () -> x = "hi";
> ^
>
>
> This also aligns the compiler with the proposed spec fix in [JDK-8043176](https://bugs.openjdk.org/browse/JDK-8043176) and fixes the inconsistency between lambdas and inner class methods shown [here](https://stackoverflow.com/questions/39881295/why-are-java-lambdas-treated-differently-from-nested-classes-with-respect-to-ins).
Archie L. Cobbs has updated the pull request incrementally with one additional commit since the last revision:
Fix @author in test to match github username per instructions.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/10381/files
- new: https://git.openjdk.org/jdk/pull/10381/files/6ae0fca3..b7bc0b6d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=10381&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=10381&range=02-03
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/10381.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10381/head:pull/10381
PR: https://git.openjdk.org/jdk/pull/10381
More information about the compiler-dev
mailing list