Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8231461

static/instance overload leads to 'unexpected static method found in unbound lookup' when resolving method reference

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 11, 14
    • Fix Version/s: 16
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b33

      Backports

        Description

        Minimized test case:

        import java.util.function.*;
         
        public class Test {
            public String foo(Object o) { return "foo"; }
            public static String foo(String o) { return "bar"; }

            public void test() {
                Function<String, String> f = Test::foo;
            }
        }

        $ javac -version
        javac 1.8.0_212
        $ javac Test.java
        <OK>

        $ ~/trunks/jdk-jdk/build/linux-x86_64-server-release/images/jdk/bin/javac -version
        javac 14-internal
        $ ~/trunks/jdk-jdk/build/linux-x86_64-server-release/images/jdk/bin/javac Test.java
        Test.java:8: error: incompatible types: invalid method reference
             Function<String, String> f = Test::foo;
             ^
            unexpected static method foo(String) found in unbound lookup
        1 error

        So it works on 8, and fails on 11, 14.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                shade Aleksey Shipilev
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: