Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : A DESCRIPTION OF THE PROBLEM : The JLS makes it clear that only the method name and parameter types distinguish a method's signature and return type and generics do not change this http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.2 However if you use generics and a different return type, you can have miltiple methods with the same signature. http://vanillajava.blogspot.com/2011/02/with-generics-return-type-is-part-of.html For more context http://stackoverflow.com/questions/5109146/does-the-method-parameters-with-different-generics-make-the-methods-have-differen/5109218#5109218 REGRESSION. Last worked in version 6u24 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : create two method with the same method name and no arguements however give them different return types and different generic declarations and the program will still compile and run. See the links provided. Note: this has the same behaviour on IBM's R9 and OpenJDK latest. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Follow the JLS spec, or correct the JLS spec to match behaviour. (I prefer the later ;) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class Main { public static void main(String... args) { Main.<Integer>print(); Main.<Short>print(); Main.<Byte>print(); Main.<Void>print(); } public static <T extends Integer> int print() { System.out.println("here - Integer"); return 0; } public static <T extends Short> short print() { System.out.println("here - Short"); return 0; } public static <T extends Byte> byte print() { System.out.println("here - Byte"); return 0; } public static <T extends Void> void print() { System.out.println("here - Void"); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Using Java 5.0 reports an eror for this code. SUPPORT : YES
|