Using Java reflection API only (java.lang.reflect package ), can we determine child (surbordinate) classes in a class hierarchy?
Asked
Active
Viewed 75 times
0
-
1I don't think so, this information cannot be known without parsing the classpath. – Arnaud Denoyelle Jun 15 '17 at 08:13
-
this might give you a clue https://stackoverflow.com/questions/205573/at-runtime-find-all-classes-in-a-java-application-that-extend-a-base-class – Shafin Mahmud Jun 15 '17 at 08:24
-
1You have to make a distinction between “all loaded subclasses” and “all potential subclasses”. Of course, a JVM knows all loaded classes, but questions like this are usually heading at the potential classes, but this is an infinite amount, as this would include classes which someone could create *after* the query, to be added to the environment dynamically. – Holger Jun 15 '17 at 10:27