RFR: 8334043: VerifyError when inner class is accessed in prologue

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jun 12 08:11:12 UTC 2024


On Tue, 11 Jun 2024 21:10:37 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> 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`).

The fix seems too strict? E.g. something like this is legal, I believe:


class A {
   Object o;
   A() { A.this.o = "Hello"; }
}

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

PR Review: https://git.openjdk.org/jdk/pull/19666#pullrequestreview-2112277001


More information about the compiler-dev mailing list