jeudi 16 septembre 2021

How to get the complete Class type of Field in Java [duplicate]

class X {
    private String y;
}

class T {
    private List<X> w;
    private void run() {
        Field f = getClass().getDeclaredField("w");
        Class t = f.getType();// t is "Class of interface java.util.List", but what I want is "Class of java.util.List<X>", how to achieve it
    }
}

I have tried getAnnotatedType or something, but nothing valuable found





Aucun commentaire:

Enregistrer un commentaire