lundi 5 novembre 2018

Reflection for finding extended classes can not find any match

I find this code to find all classes that extended from specific class in runtime. But reflection find no match class.

 Reflections reflections = new Reflections("com.mypackage.specificPackageThatNeededClassesAreExists");
 Set<Class<? extends myClass>> classes = reflections.getSubTypesOf(myClass.class);

Unfortunately nothings returns. I should mention that my classes have a generic type and i do not know if this affceted the refrection or not. For example:

public class BaseClass<T>{

}

public class ExtendedClass extends BaseClass<SpecificClass>{

}

My goal is after find these classes, call one method of them that abstract in BaseClass.





Aucun commentaire:

Enregistrer un commentaire