mardi 4 janvier 2022

Unchecked cast: 'java.lang.reflect.Type' to 'java.lang.Class

my code:

public abstract class BaseMongoServiceImpl<E> implements BaseMongoService<E> {
    private final Class<E> entityClass;

    protected BaseMongoServiceImpl() {
        ParameterizedType parameterizedType = (ParameterizedType) this.getClass().getGenericSuperclass();
        this.entityClass = (Class<E>) parameterizedType.getActualTypeArguments()[0];
    }
}

(Class<E>) parameterizedType.getActualTypeArguments()[0]; warning: Unchecked cast: 'java.lang.reflect.Type' to 'java.lang.Class'

What should I do to remove this warning without annotation?

PLZ help me!





Aucun commentaire:

Enregistrer un commentaire