Kotlin Foo::class.java “Unresolved Reference: Java” error

后端 未结 10 1251
予麋鹿
予麋鹿 2020-12-15 17:11

I am trying to convert my Java code of HomePage.class to Kotlin. I am following the instructions on Kotlin.org:

getClass()

10条回答
  •  心在旅途
    2020-12-15 17:28

    The issue is most likely that you forgot to depend on the reflection libraries which were needed for the reflective functions of Kotlin.

    On the Java platform, the runtime component required for using the reflection features is distributed as a separate JAR file (kotlin-reflect.jar). This is done to reduce the required size of the runtime library for applications that do not use reflection features. If you do use reflection, please make sure that the .jar file is added to the classpath of your project.

    Source

提交回复
热议问题