During the migration of our code base from java 1.7 to 1.8, weve got the error message "Method ... not applicable for arguments" in several places in the code, everyone follows the same pattern in using generics.
Currently, we mainly use Eclipse Mars(4.5.2) on Windows 7, but we can also confirm the behavior using Neon(4.6). Javac, and also ecjwith compliance level 1.7 can compile our code without errors.
Here is an example of Minimal, Complete and Verifiable:
public class ComplexInterfaceTest {
public static class Foo {}
public interface Bar {
void print();
}
public static class SubFooBar extends Foo implements Bar {
public void print() {
System.out.println(this.getClass().getSimpleName());
}
}
public static class FooBar<T extends Foo & Bar> {
public static <T extends Foo & Bar> FooBar<T> makeFooBar() {
return new FooBar<>();
}
public void create(T value) {
value.print();
return;
}
}
public static class Base<T extends Foo> {}
public static class Subclass extends Base<SubFooBar> {
public void doSomething(SubFooBar value) {
FooBar.makeFooBar().create(value);
}
}
public static void main(String[] args) {
new Subclass().doSomething(new SubFooBar());
}
}
doSomething , . , SubFooBar Foo Bar, <T extends Foo & Bar>, <T extends Foo & Bar> FooBar<T> makeFooBar(), T IMO SubFooBar.
:
JDK8 javac/Eclipse Luna?
Inference Eclipse Java8, Java7
, ecj. Eclipse Bugzilla, , :
- 430686 -
- 440019 - mine not
- 492838, 448793 -
Eclipse Bugzilla ecj, . , , Eclipse JLS, Javac ( , ), ecj. ecj, Javac.
- , - ?
Eclipses Bugzilla: ID # 497905 (Stephan Herrmann ) v4.7.