jddipqd
Čuven
- Učlanjen(a)
- 17.10.2000
- Poruke
- 2,555
- Poena
- 725
Imam metodu koja otprilike ovako izgleda:
I to radi kako treba, jedino se kompajler žali za cast (Class<T>)foundClass: Type safety: The cast from Class to Class<T> is actually checking against the erased type Class.
Kako izbeći ovaj warning (a da se ne koristi @SuppressWarnings("unchecked") :d)?
Kod:
public static <T> ArrayList<Class<T>> getClasses(Class<T> type) {
ArrayList<Class<T>> classes = new ArrayList<Class<T>>();
for (...) {
Class foundClass = Class.forName("someName");
if (type.isAssignableFrom(foundClass)) {
classes.add((Class<T>)foundClass);
}
}
return classes;
}
Kako izbeći ovaj warning (a da se ne koristi @SuppressWarnings("unchecked") :d)?