Community
Participate
Working Groups
Build Identifier: 20100610-0636 The following code compiles using Javac 1.6 but fails with Eclipse 3.6RC4: import java.util.Arrays; import java.util.Collection; public class Test { public static void main(String[] args) { System.out.println(Test.asArray(Arrays.asList(1, 2, 3, 4)).getClass()); System.out.println(Test.asArray(Arrays.asList(1l, 2l, 3l, 4l)).getClass()); } public static int[] asArray(Collection<Integer> list) { int[] array = new int[list.size()]; int index = 0; for (int element : list) { array[index] = element; index++; } return array; } public static long[] asArray(Collection<Long> list) { long[] array = new long[list.size()]; int index = 0; for (long element : list) { array[index] = element; index++; } return array; } } Reproducible: Always Steps to Reproduce: 1. Open attached project in Eclipse, compiles (with errors) 2.Try to compile the same classes using javac 1.6.20 on the command-line => Ok
Created attachment 172020 [details] Demonstrates the bug
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: Test.java:23: name clash: asArray(Collection<Long>) and asArray(Collection<Integ er>) have the same erasure public static long[] asArray(Collection<Long> list) { ^ Test.java:9: method asArray in class Test cannot be applied to given types System.out.println(Test.asArray(Arrays.asList(1l, 2l, 3l, ^ required: Collection<Integer> found: List<Long> 2 errors *** This bug has been marked as a duplicate of bug 289247 ***
I see. Thank You for the fast response.
Verified for 3.7M1 using build I20100802-1800