Community
Participate
Working Groups
Build Identifier: I20100603-1500 According to the JLS3.0 par 8.4.2 it should be possible to overload methods as in the following example: public class BadOverloading { public int size(List<Integer> small) { return 0; } public long size(List<Long> large) { return 0L; } } In fact type parameters are part of the method signature and then, the methods in the example have different signature. The above code causes a compilation error in eclipse, but it compiles fine with Sun's (Oracle) jdk1.6.0_20. I've tested the same code with eclipse 3.5.2 M20100211-1343 and it compiles as expected. Reproducible: Always Steps to Reproduce: Use the example in the details.
This is a defect in the Sun/Oracle compiler. See http://bugs.sun.com/view_bug.do?bug_id=6182950 fixed and released only in the JDK 7 stream. Accordingly if I compile the snippet attached to this bug using javac 7 I get: BadOverloading.java:7: name clash: size(List<Long>) and size(List<Integer>) have the same erasure public long size(List<Long> large) { ^ 1 error (In reply to comment #0) > In fact type parameters are part of the method signature and then, the methods > in the example have different signature. List<Long> and List<Integer> both decay to just List after type erasure. So there is no difference in the method signature and both methods have the same erasure and hence constitute an error according to JLS 8.4.8.3 *** This bug has been marked as a duplicate of bug 289247 ***
Verified for 3.6RC4 using build I20100603-1500.