diff --git a/bundles/org.eclipse.jdt.doc.isv/porting/3.8/faq.html b/bundles/org.eclipse.jdt.doc.isv/porting/3.8/faq.html index 5355d88..8881492 100644 --- a/bundles/org.eclipse.jdt.doc.isv/porting/3.8/faq.html +++ b/bundles/org.eclipse.jdt.doc.isv/porting/3.8/faq.html @@ -13,10 +13,52 @@

Eclipse 3.8 Plug-in Migration FAQ

    -
  1. None
  2. - +
  3. Why does my varargs code which was legal in 3.7 and earlier no longer compile with 3.8 (Juno)?
  4. +
+

Why does my varargs code which was legal in 3.7 and earlier no longer compile with 3.8 (Juno)?

+

+JDK 6 and below had a bug because of which the following code was considered legal:

+
+public class VarargPrimitiveTest {
+    public static void test(int... a) {
+        System.out.println(Arrays.toString(a));
+    }
+
+    public static  void test(Object... a) {
+        System.out.println(Arrays.toString(a));
+    }
+
+    public static void main(String[] args) {
+        test(1);
+    }
+}
+
+

However, this bug was fixed in JDK 7 and the above code now reports an ambiguous invocation error at the call site for test(..). +This was thereby fixed for Eclipse Juno via bug 346038 across all +compliance levels. This is why the above code will no longer compile with Juno.

+ +

If you still want the above code to compile in compliance < 1.7, to mimic JDK 6 or below, you can use the +system property tolerateIllegalAmbiguousVarargsInvocation to force Eclipse to tolerate the ambiguous varargs cases +such as above. This property can be set in the eclipse.ini file after the -vmargs setting as shown below:

+
+...
+-vmargs
+-DtolerateIllegalAmbiguousVarargsInvocation=true
+...
+
+

Note that with this setting, Eclipse Juno does not only mimic JDK 6 and below in letting the above code compile, but also +mimics JDK 6 and below in raising an error in cases such as below, even though they're legal in both JDK 7 and in Eclipse Juno when +the tolerateIllegalAmbiguousVarargsInvocation is disabled:

+
+class Test {
+        public static void foo(int ...i) {}
+        public static void foo(double...d) {}
+
+        public static void main(String[] args) {
+            foo(1, 2, 3);     // foo flagged ambiguous
+        }
+}
+