How do you find all subclasses of a given class in Java? -


How does one go and find all the subclasses of class given in Java (or all implementers of a given interface) is ? So far, I have a way to do this, but I think it is quite incompetent (to say the least). The method is:

  1. Get a list of all the class names on the class path
  2. Load each class and check to see if this sub-class Or the implementer is the desired class or interface

In Eclipse, there is a good feature called type hierarchy that shows it efficiently. How do one go about and programmatically do it?

There is no other way than doing this - think about how you classified - Can classrooms increase classes without scanning each class?

Eclipse can only tell you about supercars and subclasses which can be due to "efficient" quantity because it is already loaded of all types of data at that point where you Press the "Display Type Type Hierarchy" button (because it is continuously compiling your classes, knows everything about the classpath, etc.).


Comments