-
Bug
-
Resolution: Fixed
-
P3
-
11, 14
-
b33
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8259753 | 17 | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b06 |
JDK-8260141 | 16.0.1 | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b03 |
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.
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.
- backported by
-
JDK-8259753 static/instance overload leads to 'unexpected static method found in unbound lookup' when resolving method reference
-
- Resolved
-
-
JDK-8260141 static/instance overload leads to 'unexpected static method found in unbound lookup' when resolving method reference
-
- Resolved
-
- relates to
-
JDK-8008537 Missing method reference lookup error when unbound search finds a static method
-
- Resolved
-
-
JDK-8026231 Look at 'static' flag when checking method references
-
- Closed
-
-
JDK-8259721 method Resolve.ReferenceLookupResult::isSuccess can return true even for unsuccessful searches
-
- Open
-
(2 links to)