Further to the question posted here: Can you find all classes in a package using reflection? I started using the Reflections library to find all classes that subclass a given type. The source code looks like this, from an answer to the linked SO question:
Reflections ref = new Reflections(new ConfigurationBuilder()
.setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
.setUrls(ClasspathHelper.forPackage("org.somepackage"))
.filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("org.somepackage"))));
ref.getSubtypesOf(Object.class);
However, after using this code obliviously for a while, I've just discovered that it will only find classes that subclass another type within this package. It won't find classes that subclass externally defined classes, say from another user-defined package.
I'm not sure how to get around this using the Reflections library. I want all classes that declare their package as 'org.somepackage', regardless of what their supertype is. Any help?