Relates :
|
|
Relates :
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST : Bug # 5101892 explains why the Array.newInstance() method can't be retrofitted to be typesafe. Please add a new static method to the Array class that is type safe, with a signature like this one: public static <T> T[] Array.newArray(Class<T> componentType, int length) . JUSTIFICATION : Having this new type-safe method will give us a better way to write code than using the @SupressWarnings("unchecked") annotation. It will lead to cleaner code, and be a small step towards reducing caclification in the Java libraries. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I expect to be able to compile code that creates arrays without getting any warnings. ACTUAL - When I compile the code, I get warnings that I should be able to fix. ---------- BEGIN SOURCE ---------- import java.util.List; class ArrayWarnings { // @SuppressWarnings("unchecked") private List<String>[] createArray(int size) { return (List<String>[])Array.newInstance(List.class,size); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : @SupressWarnings("unchecked") provides a grezzy option, but -Xlint ignores it at the moment. ###@###.### 2005-1-31 03:21:51 GMT
|