RFR: 8336786: VerifyError with lambda capture and enclosing instance references [v4]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jul 19 18:08:32 UTC 2024


On Fri, 19 Jul 2024 17:32:51 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> Hi, please consider this fix for [JDK-8336786](https://bugs.openjdk.org/browse/JDK-8336786). After [JDK-8334037](https://bugs.openjdk.org/browse/JDK-8334037) the handling of capturing `this` in lambdas does not handle synthetic `this` variables declared in supertypes in different packages. This change adjusts the lowering of `this` references to be owned by the enclosing class, instead of the superclass, so they are handle correctly be the capture logic in `capturedDecl` in `LambdaToMethod`.
>
> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Switch to a subclass test in capturedDecl

Another possible avenue of things that can change as a result of this PR. In principle, changing the type of `this` from A to B would cause a difference in the bytecode binary qualifier. E.g. if you have `this.m()` you could see a reference to `B::m` where it used to be `A::m`.

But, after inspecting the code paths, it seems that `makeOwnerThis` can only return a plain `this` when you need an enclosing this for:
* an inner class creation expression
* a static accessor generated by Lower (to access some private/protected instance member)

So, in both cases, this PR is only changing the type of a "naked" `this` - therefore no adverse effect on binary qualifiers should occur.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20259#issuecomment-2239825272


More information about the compiler-dev mailing list