vendredi 8 janvier 2021

Java Reflection - How to get annotations used on generic type parameters?

Java's reflection API gives us almost all information about our source code. However, no matter how much I tried, couldn't find a solution for my specific problem.

I have a class like this:

public class SomeClass
{

    private String someField;

    private int someOtherField;

    private List<@NotNull String> someCollectionField;

}

I iterate all fields of this class via reflection, and try to get @NotNull annotation used in List<String>. But it seems it's impossible using reflection?

Is there any way I can do this?





Aucun commentaire:

Enregistrer un commentaire