RFR: 8318160: javac does not reject private method reference with type-variable receiver [v3]

Vicente Romero vromero at openjdk.org
Tue Oct 17 03:55:44 UTC 2023


> Please review this PR which is fixing a long standing regression in javac. Basically javac is 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;
>     }
> }
> 
> 
> this code should be rejected on the grounds that ::asString is a private method in class Test and no subclass of it should have access to this method. This regression was introduced in JDK9 so it could be that there is code depending on this bug.
> 
> TIA

Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:

  additional test

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/16210/files
  - new: https://git.openjdk.org/jdk/pull/16210/files/d540b00a..0ddafd4d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=16210&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=16210&range=01-02

  Stats: 14 lines in 2 files changed: 10 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/16210.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16210/head:pull/16210

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


More information about the compiler-dev mailing list