0

I need to make a list of all the direct subclasses of a specific class using reflection, is there any way to do it?

Epilogue
  • 63
  • 1
  • 8
  • AFAIK, There is no method to do that. – Rohit Jain Aug 07 '13 at 21:21
  • 2
    what do you mean by **possible**? – Hossein Nasr Aug 07 '13 at 21:22
  • I mean all the classes that directly extend a specific class – Epilogue Aug 07 '13 at 21:24
  • I need only the direct ones Richard and maybe there is a way to do that :P – Epilogue Aug 07 '13 at 21:26
  • http://stackoverflow.com/questions/492184/how-do-you-find-all-subclasses-of-a-given-class-in-java – JNL Aug 07 '13 at 21:26
  • Use the search, Luke! Or, you know, look at that list of things that popped up when you typed the title of your question ... – Brian Roach Aug 07 '13 at 21:27
  • There is no way of doing this within the Java API, but there are reflection libraries that can do this for you. [Reflections](https://code.google.com/p/reflections/) comes to mind. – RudolphEst Aug 07 '13 at 21:29
  • the problem is that I don't need all the subclasses but just the direct ones. Some people say in that topic that it's not possible and some other give not efficient or hard methods. Since I'm just looking for the direct ones I'd like to know if there is an easy way to do that (I don't like to scan paths for example) – Epilogue Aug 07 '13 at 21:30
  • @DomenicoToscani well, finding the direct subclasses is not easier than all subclasses. A super class doesn't store any information about its subclasses, so the only way to find them is by inspecting all classes on the class path (whether you like that or not ;-) ) – Vincent van der Weele Aug 07 '13 at 21:38

0 Answers0