RFR: 8333766: Stack overflow with anonymous class in super() parameter
Jan Lahoda
jlahoda at openjdk.org
Thu Jun 13 14:52:12 UTC 2024
On Fri, 7 Jun 2024 18:00:50 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch fixes an issue in `LambdaToMethod` where the wrong code is generated to access a symbol in the enclosing scope.
>
> `LambdaTranslationContext::addSymbol` has some logic to avoid referring to `T.this` when `T` is a type under construction. This fix works well when a lambda is directly enclosed in a `super` or `this` call, but does not scale to more complex cases, such as the one in this issue.
>
> A more complete fix needs to check whether the target `T.this` is really available via a chain of enclosing `this$n` fields. If that's not the case, then `T.this` must be captured by the lambda more directly, as there's no *path* to it from the innermost enclosing this.
>
> To detect that, I've added a method (`outerThisReachable`) which more or less mimic the lookup logic in `Lower::makeOwnerThisN`.
Makes sense to me.
-------------
Marked as reviewed by jlahoda (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19604#pullrequestreview-2116035138
More information about the compiler-dev
mailing list