I'm getting a type safety warning when I want to use the class of a generic class in a generic class, the code bellow will better explain :
class A<U, V> {
private class B<W, X> {
X x;
W w;
}
public A() {
B<U, V> c = C.someMethod(B.class); // warning here
}
static class C {
public static <T> T someMethod(Class<T> clazz) {
return null;
}
}
}
Any idea to solve this ?
Please note that B class is private.
Your work is not correct when set a type that is not important for compiler in this line:
To compiler, just B is a sign of panic. so you should write.