RFR: 8321207: javac is not accepting correct code

Vicente Romero vromero at openjdk.org
Tue Dec 5 02:29:03 UTC 2023


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

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

Commit messages:
 - 8321207: javac is not accepting correct code

Changes: https://git.openjdk.org/jdk/pull/16963/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16963&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8321207
  Stats: 45 lines in 2 files changed: 44 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/16963.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16963/head:pull/16963

PR: https://git.openjdk.org/jdk/pull/16963


More information about the compiler-dev mailing list