@@ -7,6 +7,8 @@ import org.reflections.scanners.Scanners
77import org.reflections.util.ClasspathHelper
88import org.reflections.util.ConfigurationBuilder
99
10+
11+
1012/* *
1113 * The [ModuleRegistry] object is responsible for managing all [Module] instances in the system.
1214 *
@@ -21,8 +23,18 @@ object ModuleRegistry : Loadable {
2123 override fun load (): String {
2224 Reflections (
2325 ConfigurationBuilder ()
24- .setUrls(ClasspathHelper .forPackage(" com.lambda.module.modules" ))
25- .setScanners(Scanners .SubTypes )
26+ // Let's hope the maintainer of the library releases a new version soon
27+ // because this is horrible, it takes multiple SECONDS to scan the classpath,
28+ // and it's not even that big
29+ //
30+ // The culprit may be due to [ClasspathHelper.forClassLoader()] loading
31+ // the classes from the main thread while we are in a different thread.
32+ // If this is the case I wish the maintainer a very bad day.
33+ .addUrls(ClasspathHelper .forJavaClassPath())
34+ .addUrls(ClasspathHelper .forClassLoader())
35+ .filterInputsBy { it.contains(" lambda" ) }
36+ .forPackage(" com.lambda.module.modules" )
37+ .addScanners(Scanners .SubTypes )
2638 ).getSubTypesOf(Module ::class .java).forEach { moduleClass ->
2739 moduleClass.declaredFields.find {
2840 it.name == " INSTANCE"
@@ -36,4 +48,4 @@ object ModuleRegistry : Loadable {
3648
3749 return " Registered ${modules.size} modules with ${modules.sumOf { it.settings.size }} settings"
3850 }
39- }
51+ }
0 commit comments