I did search the solution for finding all subclasses for a given class and I saw this thread
As far as I know, there are some tools to do that such as Reflections, using ClassPathScanningCandidateComponentProvider
in Spring framework, or extcos.
But after trying them all, seems none of them works for a given class in jdk (List, Map, Number, ...).
I looked into their source code, see how they work, I think the reason is because they need to get the package in which we look for the subclasses as resource, and the function classloader.getResource(String name)
, always returns null for a package name in jdk.
So, why classloader.getResource(String name)
returns null for a package name in jdk? and does anyone know a solution to get subclasses that works for jdk as well?