mardi 28 septembre 2021

How to create Reflections object?

I wanna find all classes which implement my interface. For this I use reflection provided by org.reflections:reflections:0.9.12 but the problem is I can't create an instance of the Reflections class.

My code:

Reflections reflections = new Reflections("com.example.projectName.Sortables");
Set<Class<? extends Sortable>> set = reflections.getSubTypesOf(Sortable.class);

Where "Sortable" is my interface.

The debager says

org.reflections.ReflectionsException: Scanner SubTypesScanner was not configured

I tried to put as the parameter Sortable.class, but this wasn't working. I'm confused because on this page and this page it works.





Aucun commentaire:

Enregistrer un commentaire