Grzegorz Oledzki Grzegorz Oledzki - 10 months ago 40
Java Question

List all subclasses with fully qualified names

I would like to get a list of all subclasses of a given class with their fully qualified names. I wanted to copy it from Eclipse and paste into a text file like this:


I've tried:

  • doing
    Search | Java | Type, Limit to implementors
    . But this one for some strange reasons doesn't list subclasses of subclasses, only direct descendants.

  • opening
    view for the class which prints all the subclasses in a tree component, but this view doesn't allow me to select all the rows and copy their names.

Any other tricks? There are hundreds of classes, so I wanted to avoid doing it manually.

Answer Source

Following the pattern described in one can do it programmatically. It's a shame Eclipse can't do it OOTB. Doing it in Java code allows to do the filtering with no additional cost (e.g. !(klazz.isEnum())).