RFR: 8333766: Stack overflow with anonymous class in super() parameter
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jun 7 20:51:29 UTC 2024
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`.
-------------
Commit messages:
- Fix whitespaces
- Initial push
Changes: https://git.openjdk.org/jdk/pull/19604/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19604&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8333766
Stats: 283 lines in 5 files changed: 279 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/19604.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19604/head:pull/19604
PR: https://git.openjdk.org/jdk/pull/19604
More information about the compiler-dev
mailing list