Summary: | [1.5][compiler] Compiler error with Arrays.asList in Java 5 mode? | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Mechner <eclipse> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | critical | ||
Priority: | P3 | CC: | bmiller, kent_johnson |
Version: | 3.2 | ||
Target Milestone: | 3.1.1 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
David Mechner
2005-08-04 17:47:33 EDT
If I change the code to look like this: import java.util.*; public class X { public static void main(String[] args) { double[][] d = { { 1 } , { 2 } }; List<double[]> l = Arrays.asList(d); System.out.println("List size: " + l.size()); } } The problem is more obvious. It doesn't compile and report: ---------- 1. ERROR in d:\tests_sources\X.java (at line 6) List<double[]> l = Arrays.asList(d); ^^^^^^^^^^^^^^^^ Type mismatch: cannot convert from List<double[][]> to List<double[]> ---------- 1 problem (1 error) Arrays.asList(d) is resolved to a binding where the parameter type is double[][][] instead of double[][]. The varargs should "consume" one dimension. If compiled using 1.4 compliance, it works fine. It seems that it fails only with base type array. The problem might come from the if statement in org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding line 134. Problem indeed comes from abusive removal of one vararg type dimension before launching inference. Removal should have only occur for a mono dimensional array type. Fixed both in 3.1.1 and 3.2 stream. Added VarargsTest#test034. Verified in I20050921-0010 for 3.2M2 Verified using M20050923-1430 for 3.1.1 |