RFR: 8301374: NullPointerException in MemberEnter.checkReceiver

Vicente Romero vromero at openjdk.org
Sun Feb 12 03:59:05 UTC 2023


the following incorrect code is crashing javac:

public class X {
  interface F {
    void apply(E e);
  }
  enum E {
    ONE
  }

  F f = (E.ONE) -> {};   // E.ONE?
}

there are several issues the incorrect argument to this lambda expression. The proposed solution is to issue a syntax error for the missing parameter name. IMO, this error message would be correct here and this way the compiler fails fast instead of having to deal with an erroneous lambda later on to avoid a crash like the one we have now,

TIA

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

Commit messages:
 - 8301374: NullPointerException in MemberEnter.checkReceiver

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

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


More information about the compiler-dev mailing list