Hi,
Oh, I thought maybe I encountered a bug... I thought I would show you how to reproduce it, if you're interested.
Let us have two classes, A.java and B.java, in the package "ab", and the class C.java in the package "c":
---------
package ab;
public class A {}
---------
package ab;
public class B extends A {}
---------
package c;
import ab.B;
public class C extends B {}
---------
We want to find all the classes in pacakge "c". Here is how I'm constructing the Reflections object:
Reflections reflections = new Reflections("c", new SubTypesScanner(false));
Then this code:
Collection<Class<?>> classes = reflections.getSubTypesOf(Object.class);
for (Class<?> cls : classes)
{
System.out.println("class present: " + cls);
}
does not detect C, nor does:
Collection<Class<? extends A>> classes = reflections.getSubTypesOf(A.class);
but:
Collection<Class<? extends B>> classes = reflections.getSubTypesOf(B.class);
does detect C. If I change C to:
package c;
public class C {}
then
Collection<Class<?>> classes = reflections.getSubTypesOf(Object.class);
does detect C. Is what I describe a bug, or is there a different way to get all classes, interfaces, and annotations in a package?
Thank you for the software. People say it's impossible to do some tasks in Java without it.
Tim