RFR: 8321207: javac is not accepting correct code
Jan Lahoda
jlahoda at openjdk.org
Tue Dec 5 14:44:35 UTC 2023
On Tue, 5 Dec 2023 02:24:19 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> Common code like:
>
>
> import java.util.*;
> import java.util.function.*;
>
> interface Test {
> Object O = new Object() { // but if the implicit static initializer is added here the code is accepted
> IntSupplier x(int m) {
> return () -> m;
> }
> };
> }
>
> is failing after fix for [JDK-8194743](https://bugs.openjdk.org/browse/JDK-8194743). The issue here is that method Flow.BaseAnalyzer::forEachInitializer is invoked twice once for static and another once for non-static initializers. The static-ness of the initializer is determined at this method by checking the modifiers in the corresponding AST. The problem with this is that implicit flags are added to symbols at Check::checkFlags but they don't make their way up to the AST's modifiers. The proposed fix is checking for static-ness at both the modifiers and the corresponding symbol
>
> TIA
Looks reasonable to me.
-------------
Marked as reviewed by jlahoda (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/16963#pullrequestreview-1765271265
More information about the compiler-dev
mailing list