RFR: 8322810: Lambda expressions can implement classes

Vicente Romero vromero at openjdk.org
Wed Apr 9 14:08:55 UTC 2025


Currently javac is accepting code like:


class Test {
    void m() {
        var r = (Test & Runnable) () -> System.out.println("Hello, World!");
    }
}


according to: `4.9 Intersection Types` a notional interface can't be induced here as one of the components is a class different from `j.l.Object`

With this fix this code pattern will be rejected with a compiler error

TIA

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

Commit messages:
 - modifying comment
 - 8322810: Lambda expressions can implement classes

Changes: https://git.openjdk.org/jdk/pull/24548/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24548&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322810
  Stats: 40 lines in 5 files changed: 35 ins; 3 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/24548.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24548/head:pull/24548

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


More information about the compiler-dev mailing list