realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
932 stars 57 forks source link

Kotlin 2.0.20 support #1825

Open AndreyFetisov opened 2 weeks ago

AndreyFetisov commented 2 weeks ago

How frequently does the bug occur?

Always

Description

'2.1.0' fails with the below:

Stacktrace & log output

Task :app:compileDebugKotlin FAILED
e: java.lang.NoSuchMethodError: 'java.lang.RuntimeException org.jetbrains.kotlin.backend.common.CompilationExceptionKt.wrapWithCompilationException(java.lang.Throwable, java.lang.String, org.jetbrains.kotlin.ir.declarations.IrFile, org.jetbrains.kotlin.ir.IrElement)'
    at io.realm.kotlin.compiler.RealmModelLowering.lowerFromModuleFragment(RealmModelLoweringExtension.kt:83)
    at io.realm.kotlin.compiler.RealmModelLoweringExtension.generate(RealmModelLoweringExtension.kt:53)
    at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.applyIrGenerationExtensions(convertToIr.kt:437)
    at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.runActualizationPipeline(convertToIr.kt:246)
    at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.convertToIrAndActualize(convertToIr.kt:130)
    at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize(convertToIr.kt:99)
    at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize$default(convertToIr.kt:72)
    at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertToIrAndActualizeForJvm(jvmCompilerPipeline.kt:196)
    at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertAnalyzedFirToIr(jvmCompilerPipeline.kt:169)
    at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.kt:140)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:148)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:43)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:103)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:49)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:464)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:73)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:506)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:423)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:301)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:129)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:675)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1660)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

2.1.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android

Build environment

Android Studio version: Koala | 2024.1.1 Patch 2 Android Build Tools version: 8.5.2 Gradle version: 8.7

sync-by-unito[bot] commented 2 weeks ago

➤ PM Bot commented:

Jira ticket: RKOTLIN-1123

XilinJia commented 2 weeks ago

Got the same issue, not knowing what exactly going on, reported to Kotlin: https://youtrack.jetbrains.com/issue/KT-70933/Kotlin-2.0.20-gets-NoSuchMethodError#focus=Comments-27-10373975.0-0

pvdmde commented 2 weeks ago

Title says 2.0.20 but the example goes with 2.1.0. Here to confirm the issue is with 2.0.20 which is the latest stable version. Realm should be ready to support this on release day.

XilinJia commented 2 weeks ago

Title says 2.0.20 but the example goes with 2.1.0. Here to confirm the issue is with 2.0.20 which is the latest stable version. Realm should be ready to support this on release day.

2.1.0 is the version of Realm Kotlin. 2.0.20 the version of Kotlin. Mixing the two causes this issue.

mobiletoly commented 2 weeks ago

Any ETA on having this fixed?

pvdmde commented 1 week ago

There is a PR with the fix waiting for Realm to merge and release a hotfix hopefully very soon.

nhachicha commented 1 day ago

Thanks for reporting this @AndreyFetisov some updates: While the PR in https://github.com/realm/realm-kotlin/pull/1826 address some aspects Jetbrains introduced more compiler changes:

I'm grouping potential fixes in https://github.com/realm/realm-kotlin/pull/1830 if you want to follow the progress