Let's consider following code:
public class Test49 {
interface Iface<T extends Number> {
void m(T...t);
}
public static void main(String argv[]) {
Iface<? super Integer> i = (Integer...a) -> System.out.println("lmbd");
i.m(1, 2, 3);
}
}
this code causes following error at runtime:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Number; cannot be cast to [Ljava.lang.Integer;
at Test49$$Lambda$1/1421795058.m(Unknown Source)
at Test49.main(Test49.java:9)
JDK-8049075 previously caused compiler error in similar case.
public class Test49 {
interface Iface<T extends Number> {
void m(T...t);
}
public static void main(String argv[]) {
Iface<? super Integer> i = (Integer...a) -> System.out.println("lmbd");
i.m(1, 2, 3);
}
}
this code causes following error at runtime:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Number; cannot be cast to [Ljava.lang.Integer;
at Test49$$Lambda$1/1421795058.m(Unknown Source)
at Test49.main(Test49.java:9)
- duplicates
-
JDK-8059926 java.lang.ClassCastException: [Ljava.lang.Number; cannot be cast to [Ljava.lang.Integer;
- Closed
- relates to
-
JDK-8059926 java.lang.ClassCastException: [Ljava.lang.Number; cannot be cast to [Ljava.lang.Integer;
- Closed
-
JDK-8049075 javac, wildcards and generic vararg method invocation not accepted
- Closed