I have the following code:
Reflections reflections = new Reflections(packageName, new SubTypesScanner(false));
Set<Class<? extends Action>> allClasses = reflections.getSubTypesOf(Action.class);
for (Class<?> subTypeOfActionInPackageNameClass : allClasses) {
System.out.println(subTypeOfActionInPackageNameClass.getName());
}
I would expect this to print all the class names of classes that extend Action but also all the classes that extends those classes as they indirectly extend Action too. For example C extends B extends A. If I do reflections.getSubTypesOf(A.class); It only returns class B but I would have expected it to return class C as well.
I suspected this had something to do with the SubTypesScanner but looking into that I didn't find anything to get it to return class C as well.
Now the questions are:
a) Is it supposed to behave like that?
b) Provided the answer to a is yes, is there a way to return all the classes that directly and indirectly extend class A?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire