jeudi 2 septembre 2021

ParametrizedType - empty array as result of getActualTypeArguments()

I'm testing code with reflections and I have a problem with reproduce one if statement in my code, probably because I don't understand correctly how the method works.

class TestClass {
    public Collection<TestField> field;
}
...
ParameterizedType type = (ParameterizedType) TestClass.class.getField("field").getGenericType();

Now, I am looking for a FieldType, for which the getActualTypeArguments() method will return an EMPTY Type[] array.

Based on documentation:

Note that in some cases, the returned array be empty. This can occur if this type represents a non-parameterized type nested within a parameterized type.

Unfortunately, I have a problem with understanding this fragment, so I can't design a class that will fulfill it.





Aucun commentaire:

Enregistrer un commentaire