koin-annotations
koin-annotations copied to clipboard
@ComponentScan for many annotated classes will produce too large method
trafficstars
Describe the bug
In our case, we have several hundred (around 600) annotated classes in our gradle module. Using @ComponentScan() will produce single module with single lambda containing everything found. In our case, this lambda is not compilable for JVM as it is too large.
exception: exception: java.lang.RuntimeException: Error generating class file org/koin/ksp/generated/AppModuleGencom_thomaskKt.class (compiled from [/Users/thomask/Documents/KoinComponentScanTest/build/generated/ksp/main/kotlin/org/koin/ksp/generated/AppModuleGencom$thomask.kt]): Method too large: org/koin/ksp/generated/AppModuleGencom_thomaskKt.com_thomask_AppModule$lambda$600 (Lorg/koin/core/module/Module;)Lkotlin/Unit;
To Reproduce Steps to reproduce the behavior:
- Create 600
@Singleannotated classes - Create app module with
@ComponentScan()annotation - Try to build the project
- Compilation for JVM fails I made a very simple project which demonstrates the problem
Expected behavior
Produced code is compilable to JVM even for large project with hundreds annotated classes found by single @ComponentScan
Koin project used and used version (please complete the following information):
koin-core version 3.5.6
koin-annotations 1.3.1
koin-ksp-compiler 1.3.1