RFR: 8356551: Javac rejects receiver parameter in constructor of local class in early construction context

Maurizio Cimadamore mcimadamore at openjdk.org
Tue May 13 08:52:58 UTC 2025


On Mon, 12 May 2025 22:42:03 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> But maybe I'm being to pedantic. [This patch](https://github.com/openjdk/jdk/compare/master...archiecobbs:jdk:JDK-8356551-alt2) seems to work - what do you think?

I believe that works ok. `AttrContext` is sometimes used this way, and there's a lot of "state" flags (see `isAnonymousDiamond`).

Another idea would be to just temporarily disable the `ctorPrologue` flag for the enclosing class env while attributing the receiver parameter (which should amount to the same effect) -- but that's probably a bit harder to do because you need to traverse the `env` to find exactly the one that you need to disable.

Either the patch in the current PR or the one you linked look fine to me.

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

PR Comment: https://git.openjdk.org/jdk/pull/25153#issuecomment-2875595896


More information about the compiler-dev mailing list