mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 15:41:26 +07:00
add warning "unchecked generic array creation for vararg parameter"
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
static <T> List<T> asList(T... tt) {
|
||||
System.out.println(tt);
|
||||
return null;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
static <T> List<T> asListSuppressed(T... tt) {
|
||||
System.out.println(tt);
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<String> asStringList(List<String>... tt) {
|
||||
return tt[0];
|
||||
}
|
||||
|
||||
static List<?> asQList(List<?>... tt) {
|
||||
return tt[0];
|
||||
}
|
||||
|
||||
static List<?> asIntList(int... tt) {
|
||||
System.out.println(tt);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">asList</warning>(new ArrayList<String>());
|
||||
|
||||
asListSuppressed(new ArrayList<String>());
|
||||
|
||||
//noinspection unchecked
|
||||
asList(new ArrayList<String>());
|
||||
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">asStringList</warning>(new ArrayList<String>());
|
||||
|
||||
asQList(new ArrayList<String>());
|
||||
asIntList(1);
|
||||
|
||||
final ArrayList<String> list = new ArrayList<String>();
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">asList</warning>(list);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -112,7 +112,7 @@ class Maps {
|
||||
class Client {
|
||||
void f(Date d) {
|
||||
//this call should be OK
|
||||
Maps.asMap(Maps.entry(fieldName(), "Test"),
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">Maps.asMap</warning>(Maps.entry(fieldName(), "Test"),
|
||||
Maps.entry(fieldName(), 1),
|
||||
Maps.entry(fieldName(), d));
|
||||
}
|
||||
@@ -136,7 +136,7 @@ Boolean.class, Boolean.TYPE /*,String[].class */ /*,BigDecimal.class*/);</error>
|
||||
|
||||
|
||||
public static final List<Class<? extends Serializable>> SIMPLE_TYPES_INFERRED =
|
||||
asList(String.class, Integer.class ,Long.class, Double.class, /*Date.class,*/
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">asList</warning>(String.class, Integer.class ,Long.class, Double.class, /*Date.class,*/
|
||||
Boolean.class, Boolean.TYPE ,String[].class /*,BigDecimal.class*/);
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public class MaximalType {
|
||||
return null;
|
||||
}
|
||||
{
|
||||
getParentOfType(M2.class, M.class);
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">getParentOfType</warning>(M2.class, M.class);
|
||||
}
|
||||
}
|
||||
class M extends MaximalType implements L{}
|
||||
|
||||
Reference in New Issue
Block a user