Community
Participate
Working Groups
Assume that I declare a method on class Bar like this. public static <T> void foo(T ... values) { System.out.println(values.getClass()); } and then call the method like this: Bar.<String>foo("monkey", "cat"); Bar.<String>foo(new String[] { "monkey", "cat" }); The compiler have all the facts to make the two calls equal. But it doesn't. The output of this, when compiled using the Eclipse compiler, is: class [Ljava.lang.Object; class [Ljava.lang.String; Using the Sun compiler, the output is correct: class [Ljava.lang.String; class [Ljava.lang.String; I do not think this is a duplicate of bug 92032 even if they might be related.
This is fixed in 3.2M1. d:\tests_sources>java -jar d:\org.eclipse.jdt.core_3.1.0.jar -classpath d:\jdks\jdk1.5.0_05\jre\lib\rt.jar -1.5 X.java d:\tests_sources>java X class [Ljava.lang.String; class [Ljava.lang.String; Where X is: public class X { public static <T> void foo(T ... values) { System.out.println(values.getClass()); } public static void main(String args[]) { X.<String>foo("monkey", "cat"); X.<String>foo(new String[] { "monkey", "cat" }); } } Looks like a dup of bug 102181. I will add this test case as a regression test. *** This bug has been marked as a duplicate of 102181 ***
Added org.eclipse.jdt.core.tests.compiler.regression.VarargsTest.test035