RFR: 8194743: Compiler implementation for Statements before super() [v14]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Sep 25 13:50:27 UTC 2023


On Mon, 25 Sep 2023 13:25:33 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java line 4613:
>> 
>>> 4611:      * early accesses within a constructor prologue.
>>> 4612:      */
>>> 4613:     class RefBeforeCtorCalledError extends InvalidSymbolError {
>> 
>> Why doesn't this subclass StaticError?
>
> In the new specification, constructor prologues are no longer considered a static context. Instead they're a pre-construction context (new concept). So emitting an error that says something "cannot be referenced from a static context" would be wrong. The new exception class `RefBeforeCtorCalledError` is intended to be the pre-construction context analogue of `StaticError`.

I'm aware of that - but I note that the implementation uses a STATIC_ERR under the hood. Hence my comment on using a custom static error with a custom diagnostic.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13656#discussion_r1335916998


More information about the compiler-dev mailing list