Closed sebleclerc closed 1 year ago
Hi @sebleclerc
Yes, #1002 was indeed supposed to fix this, but perhaps there is a corner case we are somehow not accounting for.
Do you know what model class this is failing for? And could you post it? That could give some hints to what might be wrong.
I did saw a list of models and pretty much all my classes where in there. Event my persistence service class. This is one of them:
internal class DBContact : RealmObject {
@PrimaryKey
var id: Int = 0
var adresse: String = ""
var idExterne: String? = null
var displayLabel: String? = null
var idTypeContact: Int = 0
}
Hi there, I still couldn't solve #1002 in my multiplatform project. We're developing using Kotiln 1.7.10 at the moment, so I didn't spend much time on this but I thought it was some issue with my grade cache not replacing realm SNAPSHOT with a more recent version. If @sebleclerc is having the same issue probably there's more going on.
This is my stack trace:
org.jetbrains.kotlin.backend.common.CompilationException: Back-end: Please report this problem https://kotl.in/issue
/Users/paolorotolo/dev/nextome/NextomeMultiplatformSDK/nextomesdk/src/commonMain/kotlin/com/nextome/sdk/multiplatform/models/NMException.kt:-1:-1
Details: Internal error in file lowering: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer org.jetbrains.kotlin.backend.common.ir.IrUtilsKt.getClassIfConstructor(org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer)'
at io.realm.kotlin.compiler.IrUtilsKt.copyTo$default(IrUtils.kt:323)
at io.realm.kotlin.compiler.RealmModelSyntheticPropertiesGeneration.addVariableProperty(RealmModelSyntheticPropertiesGeneration.kt:623)
at io.realm.kotlin.compiler.RealmModelSyntheticPropertiesGeneration.addRealmObjectInternalProperties(RealmModelSyntheticPropertiesGeneration.kt:197)
at io.realm.kotlin.compiler.RealmModelLowering.lower(RealmModelLoweringExtension.kt:89)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:101)
at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitClass(IrElementVisitorVoid.kt:111)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:92)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:92)
at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:64)
at org.jetbrains.kotlin.ir.declarations.IrFile.acceptChildren(IrFile.kt:36)
at org.jetbrains.kotlin.ir.visitors.IrVisitorsKt.acceptChildrenVoid(IrVisitors.kt:15)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitElement(Lower.kt:96)
at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitPackageFragment(IrElementVisitorVoid.kt:190)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitPackageFragment(Lower.kt:92)
at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:200)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92)
at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:198)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92)
at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:30)
at org.jetbrains.kotlin.ir.visitors.IrVisitorsKt.acceptVoid(IrVisitors.kt:11)
at org.jetbrains.kotlin.backend.common.LowerKt.runOnFilePostfix(Lower.kt:89)
at org.jetbrains.kotlin.backend.common.ClassLoweringPass$DefaultImpls.lower(Lower.kt:44)
at io.realm.kotlin.compiler.RealmModelLowering.lower(RealmModelLoweringExtension.kt:47)
at org.jetbrains.kotlin.backend.common.LowerKt.lower(Lower.kt:75)
at io.realm.kotlin.compiler.RealmModelLoweringExtension.generate(RealmModelLoweringExtension.kt:43)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda$1(JvmIrCodegenFactory.kt:183)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:99)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:215)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:53)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:230)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:158)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:475)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:125)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:373)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:318)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.rebuild(IncrementalCompilerRunner.kt:114)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:207)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:79)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1746)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer org.jetbrains.kotlin.backend.common.ir.IrUtilsKt.getClassIfConstructor(org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer)'
... 65 more
This is NMException.kt
:
class NMException: RealmObject {
@PrimaryKey
var id: Int = 0
var message: String = ""
}
@paolorotolo I'm having this error with Kotlin 1.7.20-RC
When I get back to 1.7.10, I don't have any error.
Maybe something changed between 1.7.20-BETA and 1.7.20-RC 🤔
Yeah, same for me. This happens both with Kotlin 1.7.20 Beta and RC. Project compiles fine with 1.7.10.
Those model classes look very simple and valid so looks like we still have some digging to do regarding this. Sorry for the trouble.
I can reproduce this issue with https://github.com/realm/realm-kotlin-samples/pull/29 by bumping the Multiplatform plugin to "1.7.20"
The weird thing is that our kmm-sample
, which we run on CI doesn't crash...not 100% sure what is going there, but they also do the setup slightly differently.
A small update. After the announcement of Kotlin 1.7.20 and Kotlin Multiplatform Beta, we made the decision to migrate the library to the new memory model. This has the following implications:
master
and is now available as a 1.4.0-SNAPSHOT
. You can see the full CHANGELOG here. Instructions on using a SNAPSHOT release are here.Feedback would be much appreciated if anybody can try this release. We will also be doing our own testing and then a full 1.4.0
release will be created next week unless we encounter any unforeseen bugs.
Hey @astatio, we're using Realm 1.4.0-SNAPSHOT
and all seems to work fine with Kotlin 1.7.20. Try to upgrade to 1.4.0.
My bad. I misread.
This might sound a bit off-topic, but there's no info on how to use the the SNAPSHOT version of the plugin if i were to use Kotlin instead of Groovy - the latter is an odd choice for KMM. Perhaps its extremely simple but i had to go through some documentation from Gradle's website to try to make it work and still failed to find the plugin.
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'io.realm.kotlin', version: '1.4.0-SNAPSHOT'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.realm.kotlin:io.realm.kotlin.gradle.plugin:1.4.0-SNAPSHOT')
Searched in the following repositories:
maven(https://oss.sonatype.org/content/repositories/snapshots)
Gradle Central Plugin Repository
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:238)
Looks like in order to solve this issue i have to add this to settings.gradle.kts
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "io.realm") {
useModule("io.realm.kotlin:gradle-plugin:1.4.0-SNAPSHOT")
}
}
}
repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
gradlePluginPortal()
}
}
I believe this should be in the README. I'll make a PR regarding this
Hi, we just released 1.4.0
to maven. Thanks all for your feedback and contributions 👍
Version 1.4.0 same problem with simple class.
Kotlin version 1.7.10, once change to 1.7.20 there is an issue with Compose:
compileDebugKotlin FAILED e: This version (1.3.1) of the Compose Compiler requires Kotlin version 1.7.10 but you appear to be using Kotlin version 1.7.20 which is not known to be compatible. Please fix your configuration (or
suppressKotlinVersionCompatibilityCheckbut don't say I didn't warn you!).
Any workaround?
Class and trace below:
class Exercise: RealmObject { @PrimaryKey val exerciseId: RealmUUID = RealmUUID.random() val routineComplexity: String = "" val toDo: String = "" }
` org.jetbrains.kotlin.backend.common.CompilationException: Back-end: Please report this problem https://kotl.in/issue /Users/.../AndroidStudioProjects/projectile/shared/src/commonMain/kotlin/com/kikkoapps/application/hangboardtraining/data/Exercise.kt:-1:-1 Details: Internal error in file lowering: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.declarations.IrValueParameter org.jetbrains.kotlin.ir.util.IrUtilsKt.copyTo$default(org.jetbrains.kotlin.ir.declarations.IrValueParameter, org.jetbrains.kotlin.ir.declarations.IrFunction, org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin, int, int, int, org.jetbrains.kotlin.name.Name, java.util.Map, org.jetbrains.kotlin.ir.types.IrType, org.jetbrains.kotlin.ir.types.IrType, org.jetbrains.kotlin.ir.expressions.IrExpressionBody, boolean, boolean, boolean, int, java.lang.Object)' at io.realm.kotlin.compiler.RealmModelSyntheticPropertiesGeneration.addVariableProperty(RealmModelSyntheticPropertiesGeneration.kt:624) at io.realm.kotlin.compiler.RealmModelSyntheticPropertiesGeneration.addRealmObjectInternalProperties(RealmModelSyntheticPropertiesGeneration.kt:198) at io.realm.kotlin.compiler.RealmModelLowering.lower(RealmModelLoweringExtension.kt:89) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:101) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitClass(IrElementVisitorVoid.kt:44) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:92) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:92) at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:46) at org.jetbrains.kotlin.ir.declarations.IrFile.acceptChildren(IrFile.kt:28) at org.jetbrains.kotlin.ir.visitors.IrVisitorsKt.acceptChildrenVoid(IrVisitors.kt:15) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitElement(Lower.kt:96) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitPackageFragment(IrElementVisitorVoid.kt:30) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitPackageFragment(Lower.kt:92) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:37) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92) at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:38) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92) at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitFile(Lower.kt:92) at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:22) at org.jetbrains.kotlin.ir.visitors.IrVisitorsKt.acceptVoid(IrVisitors.kt:11) at org.jetbrains.kotlin.backend.common.LowerKt.runOnFilePostfix(Lower.kt:89) at org.jetbrains.kotlin.backend.common.ClassLoweringPass$DefaultImpls.lower(Lower.kt:44) at io.realm.kotlin.compiler.RealmModelLowering.lower(RealmModelLoweringExtension.kt:47) at org.jetbrains.kotlin.backend.common.LowerKt.lower(Lower.kt:75) at io.realm.kotlin.compiler.RealmModelLoweringExtension.generate(RealmModelLoweringExtension.kt:43) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda-1(JvmIrCodegenFactory.kt:162) at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:99) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:194) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:53) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:232) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:115) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:60) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:157) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:477) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:127) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:366) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:311) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:175) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:75) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1739) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.declarations.IrValueParameter org.jetbrains.kotlin.ir.util.IrUtilsKt.copyTo$default(org.jetbrains.kotlin.ir.declarations.IrValueParameter, org.jetbrains.kotlin.ir.declarations.IrFunction, org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin, int, int, int, org.jetbrains.kotlin.name.Name, java.util.Map, org.jetbrains.kotlin.ir.types.IrType, org.jetbrains.kotlin.ir.types.IrType, org.jetbrains.kotlin.ir.expressions.IrExpressionBody, boolean, boolean, boolean, int, java.lang.Object)' ... 63 more
`
Hi!
I came across this issue: https://github.com/realm/realm-kotlin/issues/1002 I seems to have a similar error but WITH the fix in place. I did update my project with Kotlin 1.7.20-RC and my realm module fails with
Now I did setup my project to use the realm 1.2.0-SNAPSHOT and I'm pretty sure it's used because the error originate from
IrUtils.kt:323
which if I understand correctly is what was introduced to fix issue 1002.Is this another problem or something else?
Thanks in advance