RFR: 8334043: VerifyError when inner class is accessed in prologue
Archie Cobbs
acobbs at openjdk.org
Tue Jun 11 21:16:33 UTC 2024
The new flexible constructors logic creates an exception to the normal rule preventing early access to `this` in an early construction context by allowing assignments to instance fields. The check for this exception is performed by `Resolve.isAllowedEarlyReference()`, but this method was incorrectlly assuming that the expression was simpler than it can sometimes be, for example, for more complicated assignment expressions like `this.new InnerClass().foo = 123`.
This change verifies that the expression actually looks like either `Y = Z` or `X.Y = Z` where `X` is a simple reference to the current class' `this` instance (i.e., `this`, or `ThisClass.this`).
-------------
Commit messages:
- Disallow early references embedded in complicated assignments statements.
Changes: https://git.openjdk.org/jdk/pull/19666/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19666&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8334043
Stats: 27 lines in 3 files changed: 25 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/19666.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19666/head:pull/19666
PR: https://git.openjdk.org/jdk/pull/19666
More information about the compiler-dev
mailing list