koin-annotations icon indicating copy to clipboard operation
koin-annotations copied to clipboard

@ComponentScan for many annotated classes will produce too large method

Open ThomasKNR opened this issue 1 year ago • 0 comments
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:

  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

ThomasKNR avatar Jul 23 '24 07:07 ThomasKNR