-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
11
-
x86_64
-
windows_7
ADDITIONAL SYSTEM INFORMATION :
Worked on java 1.8.0_231 Oracle
Not working on java 11.0.3 Oracle
A DESCRIPTION OF THE PROBLEM :
When you refer to a static method by method reference, if it shares the name with a non static method, the code will fail to compile, even if the signatures are different
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation and run
ACTUAL -
Compilation error with message:
Error:(26, 32) java: incompatible types: cannot infer type-variable(s) R
(argument mismatch; invalid method reference
unexpected static method setField(Bob) found in unbound lookup)
---------- BEGIN SOURCE ----------
import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.function.Function;
public class Bob {
public static Function<Object, Bob> setField(final Bob builder) {
return builder::setField;
}
public Bob setField(final Object t) {
return this;
}
@Nested
class BobTest {
@Test
void test() {
final Set<Bob> bobSet = ImmutableSet.of(new Bob());
bobSet.stream().map(Bob::setField);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Rename the static function
FREQUENCY : always
Worked on java 1.8.0_231 Oracle
Not working on java 11.0.3 Oracle
A DESCRIPTION OF THE PROBLEM :
When you refer to a static method by method reference, if it shares the name with a non static method, the code will fail to compile, even if the signatures are different
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation and run
ACTUAL -
Compilation error with message:
Error:(26, 32) java: incompatible types: cannot infer type-variable(s) R
(argument mismatch; invalid method reference
unexpected static method setField(Bob) found in unbound lookup)
---------- BEGIN SOURCE ----------
import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.function.Function;
public class Bob {
public static Function<Object, Bob> setField(final Bob builder) {
return builder::setField;
}
public Bob setField(final Object t) {
return this;
}
@Nested
class BobTest {
@Test
void test() {
final Set<Bob> bobSet = ImmutableSet.of(new Bob());
bobSet.stream().map(Bob::setField);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Rename the static function
FREQUENCY : always