mardi 17 décembre 2019

Reflections doesnt find object subtypes

I am trying to get all the classes in a package by using Reflections. When I use code of a concrete class (A in this example) it works and prints the subclases information (B extends A so it prints B information), but when I use it with Object class it doesnt work. How can I fix it?

This code works:

Reflections reflections = new Reflections(REFLECTION_PACKAGE);
Set<Class<? extends A>> allClasses = reflections.getSubTypesOf(A.class);

System.out.println("numberOfLCasses: " + allClasses.size());
System.out.println("classes: " + allClasses.toString());

This code doesn't:

Reflections reflections = new Reflections(REFLECTION_PACKAGE);
Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);

System.out.println("numberOfLCasses: " + allClasses.size());
System.out.println("classes: " + allClasses.toString());




Aucun commentaire:

Enregistrer un commentaire