InsertKoinIO / koin-annotations

Koin Annotations - About Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform insert-koin.io
https://insert-koin.io
Apache License 2.0
163 stars 44 forks source link

@ComponentScan for many annotated classes will produce too large method #147

Open ThomasKNR opened 4 months ago

ThomasKNR commented 4 months ago

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:

  1. Create 600 @Single annotated classes
  2. Create app module with @ComponentScan() annotation
  3. Try to build the project
  4. 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