Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Quoting from project coin proposal at the following URL: http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000316.html "When a programmer tries to invoke a varargs (variable arity) method with a non-reifiable varargs type, the compiler currently generates an "unsafe operation" warning. This proposal moves the warning from the call site to the method declaration." BEFORE: static <T> List<T> asList(T... elements) { ... } static List<Callable<String>> stringFactories() { Callable<String> a, b, c; ... // Warning: "uses unchecked or unsafe operations" return asList(a, b, c); } AFTER (1): // Warning: "enables unsafe generic array creation" static <T> List<T> asList(T... elements) { ... } static List<Callable<String>> stringFactories() { Callable<String> a, b, c; ... // Warning: "uses unchecked or unsafe operations" return asList(a, b, c); } AFTER (2): @SuppressWarnings("generic-varargs") static <T> List<T> asList(T... elements) { ... } //no warning static List<Callable<String>> stringFactories() { Callable<String> a, b, c; ... // no warning return asList(a, b, c); }
|