Open vovahost opened 2 years ago
Could you share the whole reproducer, please?
Also, which Compose/Kotlin versions do you use?
Resurrecting this issue since this is happening on 1.2.0 with Kotlin 1.7.10 (and 1.7.0) when building an Idea plugin with Compose UI.
ava.lang.ClassCastException: androidx.compose.runtime.internal.ComposableLambdaImpl cannot be cast to kotlin.jvm.functions.Function2 at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:74) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3193) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3183) at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:252) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3183) at androidx.compose.runtime.ComposerImpl.composeContent$runtime(Composer.kt:3119) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:578) at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:811) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:513) at androidx.compose.ui.platform.Wrapper_skikoKt.setContent(Wrapper.skiko.kt:45) at androidx.compose.ui.ComposeScene.setContent$ui(ComposeScene.skiko.kt:337) at androidx.compose.ui.ComposeScene.setContent$ui$default(ComposeScene.skiko.kt:318) at androidx.compose.ui.awt.ComposeLayer$setContent$3$1.invoke(ComposeLayer.desktop.kt:399) at androidx.compose.ui.awt.ComposeLayer$setContent$3$1.invoke(ComposeLayer.desktop.kt:398) at androidx.compose.ui.awt.ComposeLayer.catchExceptions(ComposeLayer.desktop.kt:96) at androidx.compose.ui.awt.ComposeLayer.access$catchExceptions(ComposeLayer.desktop.kt:76) at androidx.compose.ui.awt.ComposeLayer$setContent$3.invoke(ComposeLayer.desktop.kt:398) at androidx.compose.ui.awt.ComposeLayer$setContent$3.invoke(ComposeLayer.desktop.kt:397) at androidx.compose.ui.awt.ComposeLayer.initContent(ComposeLayer.desktop.kt:413) at androidx.compose.ui.awt.ComposeLayer.access$initContent(ComposeLayer.desktop.kt:76) at androidx.compose.ui.awt.ComposeLayer$ComponentImpl.addNotify(ComposeLayer.desktop.kt:203) at java.desktop/java.awt.Container.addImpl(Container.java:1146) at java.desktop/javax.swing.JLayeredPane.addImpl(JLayeredPane.java:237) at java.desktop/java.awt.Container.add(Container.java:489) at androidx.compose.ui.awt.ComposePanel.addNotify(ComposePanel.desktop.kt:181) at java.desktop/java.awt.Container.addNotify(Container.java:2800) at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4791) at java.desktop/java.awt.Container.addNotify(Container.java:2800) at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4791) at java.desktop/java.awt.Container.addNotify(Container.java:2800) at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4791) at java.desktop/java.awt.Container.addNotify(Container.java:2800) at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4791) at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:733) at java.desktop/java.awt.Container.addNotify(Container.java:2800) at java.desktop/java.awt.Window.addNotify(Window.java:786) at java.desktop/java.awt.Dialog.addNotify(Dialog.java:752) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.addNotify(DialogWrapperPeerImpl.java:638) at java.desktop/java.awt.Window.pack(Window.java:824) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:649) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:437) at com.intellij.openapi.ui.DialogWrapper.doShow(DialogWrapper.java:1702) at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1661) at com.infinum.intellij.plugins.warden.ui.actions.WardenAction.actionPerformed(WardenAction.kt:19) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:296) at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:281) at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:285) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:401) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369) at java.desktop/com.apple.laf.ScreenMenuItemCheckbox.itemStateChanged(ScreenMenuItemCheckbox.java:198) at java.desktop/java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:396) at java.desktop/java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:364) at java.desktop/java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:375) at java.desktop/java.awt.MenuComponent.dispatchEvent(MenuComponent.java:363) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:967) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:839) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:450) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:449) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:503) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Here is the complete project reproducer to test out, if needed. https://github.com/bojankoma/intellij-gradle-warden
Sorry to spam a little, but this can be reproduced now on each run, not just occasionally.
Idea UI Run tab shows errors, in order:
Caused by: java.lang.NoClassDefFoundError: kotlin/reflect/TypesJVMKt
Caused by: java.lang.ClassNotFoundException: kotlin.reflect.TypesJVMKt PluginClassLoader[PluginDescriptor(name=Gradle Warden, id=com.infinum.intellij.plugins.warden, path=/Users/bojan/Workspace/IntelliJ/Plugins/Warden/build/idea-sandbox/plugins/Warden, version=1.0.1)] com.intellij.ide.plugins.cl.PluginClassLoader@112d4d55
Caused by: java.lang.NoClassDefFoundError: kotlin/reflect/TypesJVMKt
@akurasov let me know if there is something I can try or do to mitigate this, but at the moment building Idea plugins with Compose is not possible and we are blocked.
I experienced this just now while running an Android UI test using AndroidComposeTestRule
.
We have had a shared base class for running these tests before.
So:
open TestBase {
..
}
fun FeatureTest: TestBase {
@Test
fun testA() {
}
}
This has worked fine for months, but I recently tried to create another layer to share logic between the tests:
open TestBase {
..
}
open FeatureTestBase: TestBase {
..
}
fun FeatureTest: FeatureTestBase {
@Test
fun testA() {
}
}
And now the tests consistently fail. There are no constructor parameters in the FeatureTestBase
nor TestBase
.
Stack:
02-09 12:55:53.809 7058 7091 E TestRunner: java.lang.ClassCastException: androidx.compose.runtime.internal.ComposableLambdaImpl cannot be cast to kotlin.jvm.functions.Function0
02-09 12:55:53.809 7058 7091 E TestRunner: at removed_test_name
02-09 12:55:53.809 7058 7091 E TestRunner: at java.lang.reflect.Method.invoke(Native Method)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:148)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:147)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidComposeUiTestImpl.withDisposableContent(ComposeUiTest.android.kt:476)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1$1$1.invoke(ComposeUiTest.android.kt:294)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withTextInputService(ComposeUiTest.android.kt:360)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withTextInputService(ComposeUiTest.android.kt:217)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1$1.invoke(ComposeUiTest.android.kt:293)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withComposeIdlingResource(ComposeUiTest.android.kt:347)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withComposeIdlingResource(ComposeUiTest.android.kt:217)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1.invoke(ComposeUiTest.android.kt:292)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withWindowRecomposer(ComposeUiTest.android.kt:321)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withWindowRecomposer(ComposeUiTest.android.kt:217)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1.invoke(ComposeUiTest.android.kt:291)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withTestCoroutines(ComposeUiTest.android.kt:334)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withTestCoroutines(ComposeUiTest.android.kt:217)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1.invoke(ComposeUiTest.android.kt:290)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.EspressoLink.withStrategy(EspressoLink.android.kt:66)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1.invoke(ComposeUiTest.android.kt:289)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.IdlingResourceRegistry.withRegistry(IdlingResourceRegistry.jvm.kt:157)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1.invoke(ComposeUiTest.android.kt:288)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.ComposeRootRegistry.withRegistry(ComposeRootRegistry.android.kt:146)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.runTest(ComposeUiTest.android.kt:287)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1.evaluate(AndroidComposeTestRule.android.kt:147)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.Suite.runChild(Suite.java:128)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.Suite.runChild(Suite.java:27)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
02-09 12:55:53.809 7058 7091 E TestRunner: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
02-09 12:55:53.809 7058 7091 E TestRunner: at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446)
02-09 12:55:53.809 7058 7091 E TestRunner: at removed_class_name
02-09 12:55:53.809 7058 7091 E TestRunner: at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2361)
02-09 12:55:53.810 7058 7091 E TestRunner: ----- end exception -----
We are using:
Current status:
I tried to use kotlin 1.9.20 and CM 1.5.10 and it seems to work good without ClassCastException issue. Please give it a try!
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
I'm getting this error occasionally:
The code which would cause this error:
The error is thrown when
setContent()
is called. Once the error happens every Run will throw the error again. Rebuilding the project and running it again fixes the error until it happens sometime again.