Why it is possible to compile class with two methods with equal signatures?
"foo" methods have only different return types.
But return type is not a part of method signature in java.
Does java compiler creates bridge methods in this case?
If yes - how real code will look like?
There are following warnings for foo methods:
Method foo(GenClass) has the same erasure foo(GenClass) as another method in type test
If uncomment bar methods, there will be following errors for bar methods:
Method bar(GenClass) has the same erasure bar(GenClass) as another method in type test
class GenClass<T> {
}
public class test {
public static void main(String[] args) {
}
public static Integer foo(GenClass<Integer> criteria) {
System.out.println("Integer");
return null;
}
public static String foo(GenClass<String> criteria) {
System.out.println("String");
return null;
}
/*public static void bar(GenClass<Integer> criteria) {
System.out.println("Integer");
}
public static void bar(GenClass<String> criteria) {
System.out.println("String");
}*/
}
D:\tools\java\jdk1.6.0_37_32\bin>java -version
java version "1.6.0_38"
Java(TM) SE Runtime Environment (build 1.6.0_38-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)