为什么kotlin在foreach中创建两个对象时会抛出“Verifier拒绝类”错误?

时间:2018-04-26 22:10:54

标签: java android kotlin

我遇到了一种非常奇怪的行为。我有一个类型为Any的列表,我使用forEach在其中进行迭代。问题是我在内部使用对列表中当前对象的引用创建了两个对象,它只是崩溃了。

projectLogEntries.forEach{
            if (it is ProjectQuery.ProjectLogEntry){
                val projectLogEntry = ProjectLogEntry(
                        createdAt = Date(),
                        remoteId =  it.id()?.toLong(),
                        remoteUserId = it.device()?.user()?.id()?.toLong(),
                        projectId = it.project()?.id()?.toLong()!!,
                        comment = "asdf"
                )

                val user =  User(
                        createdAt = Date(),
                        nameUser = it.device()?.user()?.name(),
                        remoteId = it.device()?.user()?.id()?.toLong(),
                        email = it.device()?.user()?.email() ?: "No email",
                        lastName = it.device()?.user()?.lastName() ?: "No last name"
                )
}

我收到此错误。

java.lang.VerifyError: Verifier rejected class com.rhodar.mobile.codescrum.rhodarsitepacks.data.respositories.ProjectRepository: void com.rhodar.mobile.codescrum.rhodarsitepacks.data.respositories.ProjectRepository.saveProjectLogEntriesTest(java.util.List) failed to verify: void com.rhodar.mobile.codescrum.rhodarsitepacks.data.respositories.ProjectRepository.saveProjectLogEntriesTest(java.util.List): [0x128] copy2 v24<-v6 type=Precise Low-half Constant: 0/Zero/null (declaration of 'com.rhodar.mobile.codescrum.rhodarsitepacks.data.respositories.ProjectRepository' appears in /data/app/com.rhodar.mobile.codescrum.rhodarsitepacks.development-g3RDRVMlGdFpZFzB8fi1lQ==/split_lib_slice_1_apk.apk)
        at com.rhodar.mobile.codescrum.rhodarsitepacks.ui.MainProjectActivity.<init>(MainProjectActivity.kt:29)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

知道为什么会这样吗?

0 个答案:

没有答案