下面的代码在Java 7中编译并运行正常,但无法在Java 1.8.0 u25中编译:
public class GenericTest {
public static class GenericClass<T> {
T value;
public GenericClass(T value) {
this.value = value;
}
}
public static class SecondGenericClass<T> {
T value;
public SecondGenericClass(T value) {
this.value = value;
}
}
public static<T >void verifyThat(SecondGenericClass<T> actual, GenericClass<T> matcher) {
}
public static<T >void verifyThat(T actual, GenericClass<T> matcher) {
}
@Test
public void testName() throws Exception {
verifyThat(new SecondGenericClass<>(""), new GenericClass<>(""));
}
}
Run Code Online (Sandbox Code Playgroud)
Java 8中的错误消息如下所示:
Error:(33, 9) java: reference to verifyThat is …Run Code Online (Sandbox Code Playgroud)