If I have
Reflections reflections = new Reflections("my.package", classLoader, new SubTypesScanner(false));
then this finds my enum classes
Set<Class<? extends Enum>> enums = reflections.getSubTypesOf(Enum.class);
but this doesn't
Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
Is there a reason for this?
Reproducible example:
package cupawntae;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
public class Reflector {
public static void main(String[] args) {
Reflections reflections = new Reflections("cupawntae", Reflector.class.getClassLoader(), new SubTypesScanner(false));
System.out.println("Objects: " + reflections.getSubTypesOf(Object.class));
System.out.println("Enums: " + reflections.getSubTypesOf(Enum.class));
System.out.println("Enum's superclass: " + Enum.class.getSuperclass());
}
}
Enum class:
package cupawntae;
public enum MyEnum {
}
Output:
Objects: [class cupawntae.Reflector]
Enums: [class cupawntae.MyEnum]
Enum's superclass: class java.lang.Object
Aucun commentaire:
Enregistrer un commentaire