I have an interface class EnumIF
public interface EnumIF<T> {
T getVal();
}
And have a method that is generic for classes implementing this interface
public static <E extends EnumIF> E find(Class<E> type) {
...
}
I cannot pass a wildcard generic class from some reflection code;
Class<? extends EnumIF> fieldClazz = (Class<? extends EnumIF>) field.getType();
EnumIF findet = find(fieldClazz) //compiler error
Why can't I pass wildcard generic generated from reflection as regular generic type? How to do this transition?
Aucun commentaire:
Enregistrer un commentaire