How to get KClass of @file:JvmName


#1

@file:JvmName(“EncryptionModule”)
@file:Module

package com.dfdfdfd.di.module

@Provides
@Singleton
fun getEncryptionService(context: Context): EncryptionService {
    return EncryptionServiceDefault(context)
}

I wrote in this way to retrieve class with static functions.

@Singleton
@Component(modules = [
ApplicationModule::class,
EncryptionModule::class, //error Unresolved reference EncryptionModule
DataModule::class])

Please, help me. How to retrieve const instance of KClass in this case?


#2

Did you figure this out?


#3

At Kotlin language level top level functions are independent of the file they are declared in. They belong directly to their package. @JvmName annotations do not change this, they merely change details of the compilation result not the validity of your Kotlin (unless you use it to avoid platform issues on uncompilable Kotlin). On the JVM a class is needed that contains these static members. It still isn’t possible to create instances of them. Instead you may be thinking about an object rather than a toplevel.


#4

No