Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8318160 javac does not reject private method reference with type-variable receiver
  3. JDK-8325070

Release Note: The `javac` Compiler Should Not Accept Private Method References with a Type Variable Receiver

XMLWordPrintable

      Prior to JDK 22, the `javac` compiler was accepting private method references with a type variable receiver. This implies that the `javac` compiler was accepting code like:

      ```
      import java.util.function.*;
      class Test {
          private String asString() {
              return "bar";
          }

          static <T extends Test> Function<T, String> foo() {
              return T::asString;
          }
      }
      ```

      Starting from JDK 22 private method references with type variable receiver will be rejected by the `javac` compiler.

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: