FULL PRODUCT VERSION :
javac 1.6.0_07
javac 1.5.0_16
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.18-92.1.22.el5
Mac OS X 10.5.6
A DESCRIPTION OF THE PROBLEM :
A simple, no-argument invocation of Arrays.asList prompts an unchecked warning.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the given code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No warnings. (Expected behavior occurs in Eclipse.) The compiler should infer that T = Object and determine that an empty Object[] must be allocated for the invocation.
ACTUAL -
A warning occurs. The compiler seems to have failed to substitute Object for T before verifying that the varargs arguments have a reifiable type. Note that the error message makes no sense -- the type "T[]" is meaningless in the calling context.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
EmptyAsList.java:3: warning: [unchecked] unchecked generic array creation of type T[] for varargs parameter
java.util.Arrays.asList();
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class EmptyAsList {
public static void main(String... args) {
java.util.Arrays.asList();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Provide an explicit type argument: Arrays.<Object>asList()