Summary: | [1.5][compiler] Strange compiler warning "A generic array of ... is created for a varargs parameter" | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | CC: | daniel_megert, max.gilead, thanson |
Version: | 3.2 | ||
Target Milestone: | 3.3 RC1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Markus Keller
2006-08-16 04:49:31 EDT
Re: spaces around '&' in intersection type It may confuse readers since they wouldn't see an intersection type as one piece, but as multiple fragments... Re: type safety issue This behavior is described in the spec I think. Need to double check on this. Tim, pls have a look at it. Javac doesn't report the warning, but technically I think it should. An intersection type isn't reifiable, though it seems to treat it as such. Comparable<?>[] is tolerated by the spec as an unbound parameterized type (but this is an exception). As per JLS4.7, an intersection type isn't reifiable, and should thus be warned against for varargs invocations. Added GenericTypeTest#test1136 Closing as invalid. Never mind, if I ever need to avoid the unchecked warning, I can always write it like this: Arrays.<Comparable<?>>asList(1, "X") // no unchecked warning in ecj or javac However, it's interesting that both ecj and javac protest against Arrays.asList(new ThreadLocal<Runnable>(), new ThreadLocal<Cloneable>()); but accept Arrays.<ThreadLocal<?>>asList( new ThreadLocal<Runnable>(), new ThreadLocal<Cloneable>()); (probably because inference for the former yields ThreadLocal<? extends Object>). Exactly. I agree this doesn't feel intuitive (blame the spec <g>). |