Unchecked cast warnings in generic method on parameter that must be used in a List
问题 In the code below, the type parameter D can be either a List<Byte> or a List<List<Byte>> (it is the third generic parameter in the Fields<?, ?, D> interface but still I might omit it there - but it is present also in the return type of the method). Can't seem to find a way to tell the compiler this - get Unchecked cast warnings in the lines marked //* : public static <D, K, T extends Enum<T> & Fields<?, ?, D>> List<EnumMap<T, D>> getEntries(InputStream is, Class<T> fields) throws IOException