vendredi 4 décembre 2015

Using Reflexions library with JBoss

I'm trying to find all the classes present in a package of my app (deployed in JBoss AS 7.1). Most of the stackoverflow posts says to use Reflexions, but it's not working:

new Reflections("java.lang", new SubTypesScanner(false)).getAllTypes()

Throws a org.reflexion.ReflexionsException : Couldn't find subtypes of Object. Make sure SubTypesScanner initialized to include Object class - new SubTypesScanner(false)

I also tried to use guava's ClassPath class, not better :

ClassPath.from(Thread.currentThread().getContextClassLoader()).getAllClasses()

Returns me 469 classes, mainly com.sun.* and org.jboss.* I don't even have java.lang.*, and I don't see my classes

Using IntelliJ debugger, I see that Thread.currentThread().getContextClassLoader() is a org.jboss.modules.ModuleClassLoader and contains 2637 classes, including my classes, but I don't know how to access these classes.

Thread.currentThread().getContextClassLoader().getPackage("my.package") is also working

The same code in a main() works great.

How can I get the list of the classes in this package?





Aucun commentaire:

Enregistrer un commentaire