RFR: 8194743: Compiler implementation for Statements before super() [v14]
Archie Cobbs
acobbs at openjdk.org
Mon Sep 25 13:35:15 UTC 2023
On Mon, 25 Sep 2023 08:50:03 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove obsolete flag "constructorArgs".
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 485:
>
>> 483: // Do something with all static or non-static field initializers and initialization blocks.
>> 484: // Note: This method also sends nested class definitions to the handler.
>> 485: protected void forEachInitializer(JCClassDecl classDef, boolean statik, Consumer<? super JCTree> handler) {
>
> Suggestion:
>
> protected void forEachInitializer(JCClassDecl classDef, boolean isStatic, Consumer<? super JCTree> handler) {
Fixed in 150d794c1e6, thanks.
> 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`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13656#discussion_r1335890156
PR Review Comment: https://git.openjdk.org/jdk/pull/13656#discussion_r1335887916
More information about the compiler-dev
mailing list