Community
Participate
Working Groups
Since Eclipse SDK 3.2RC2 there is an ambigous error for the following method signatures: public void setItem(Object id, Object value, String... groups); public void setItem(Item item, String... groups); Where the methode invocation c.setItem(new Item("id", "value"), "group-a", "group-b"); becomes ambigous. This code works properly with Eclipse SDK 3.1.2, jdk1.5.0_01 and jdk1.5.0_04. That means that always the expected methode was called.
Test case: public class X { public void setItem(Object id, Object value, String... groups) {} public void setItem(Item item, String... groups) {} public static void main(String[] args) { X x = new X(); x.setItem(new Item("id", "value"), "group-a", "group-b"); } } class Item { public Item(String s, String s1) {} } We report: ---------- 1. ERROR in D:\tests_sources\X.java (at line 8) x.setItem(new Item("id", "value"), "group-a", "group-b"); ^^^^^^^ The method setItem(Object, Object, String[]) is ambiguous for the type X ---------- 1 problem (1 error) javac 1.5.0_07 and 6.0b81 compile that code successfully.
Disassembled code: 0 new X [2] 3 dup 4 invokespecial X() [3] 7 astore_1 8 aload_1 9 new Item [4] 12 dup 13 ldc <String "id"> [5] 15 ldc <String "value"> [6] 17 invokespecial Item(java.lang.String, java.lang.String) [7] 20 iconst_2 21 anewarray java.lang.String [8] 24 dup 25 iconst_0 26 ldc <String "group-a"> [9] 28 aastore 29 dup 30 iconst_1 31 ldc <String "group-b"> [10] 33 aastore 34 invokevirtual X.setItem(Item, java.lang.String[]) : void [11] 37 return So the second one is called.
Created attachment 40365 [details] Patch Straight forward fix for vararg methods with different number of parameters
Darin, Dani - please approve the attached patch
Approving for 3.2 RC3.
Jeff - can you give this one a thumbs up?
+1 for RC3
+1
Added VarargsTest #47
Released into HEAD
Verified for 3.2RC3 using I20060504-1600.
Works well again. Thank you for quick work. Verified with: Version: 3.2.0 Build id: I20060504-2000