You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to convert some Kotlin code, which was written for the JVM and uses some Java libraries, to JavaScript (and if that works later to Wasm and C too). This code also uses Kotlin serialization (JSON) which I thought would be no problem because Kotlin serialization does not use reflection. But it turns out that this does not work because some standard Java methods are missing.
Is there any chance that these three missing methods could be implemented?
The full error output is:
Executing 'build'…
> Task :copyWasmGCRuntime
> Task :checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :processResources NO-SOURCE
> Task :processTeavmResources NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :compileKotlin
> Task :compileJava NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTeavmKotlin NO-SOURCE
> Task :compileTeavmJava NO-SOURCE
> Task :teavmClasses UP-TO-DATE
> Task :generateWasmGC FAILED
[Incubating] Problems report is available at: file:///Users/mpaus/Projects/tmp/TeaVMTestGradle/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
3 actionable tasks: 3 executed
Method java.lang.Class.isAnonymousClass()Z was not found
at kotlin.jvm.internal.ClassReference$Companion.getClassSimpleName(ClassReference.kt:166)
at kotlin.jvm.internal.ClassReference.getSimpleName(ClassReference.kt:12)
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:114)
at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:250)
at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:99)
at kotlinx.serialization.json.Json.encodeToString(Json.kt:125)
at de.mpmediasoft.teavmtest.Client$Companion.dispatch(Client.kt:68)
at de.mpmediasoft.teavmtest.Client.dispatch(-1)
at de.mpmediasoft.teavmtest.Client.dispatch$exported$1
Method java.lang.Class.getEnclosingMethod()Ljava/lang/reflect/Method; was not found
at kotlin.jvm.internal.ClassReference$Companion.getClassSimpleName(ClassReference.kt:169)
at kotlin.jvm.internal.ClassReference.getSimpleName(ClassReference.kt:12)
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:114)
at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:250)
at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:99)
at kotlinx.serialization.json.Json.encodeToString(Json.kt:125)
at de.mpmediasoft.teavmtest.Client$Companion.dispatch(Client.kt:68)
at de.mpmediasoft.teavmtest.Client.dispatch(-1)
at de.mpmediasoft.teavmtest.Client.dispatch$exported$1
Method java.lang.Class.getEnclosingConstructor()Ljava/lang/reflect/Constructor; was not found
at kotlin.jvm.internal.ClassReference$Companion.getClassSimpleName(ClassReference.kt:170)
at kotlin.jvm.internal.ClassReference.getSimpleName(ClassReference.kt:12)
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:114)
at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:250)
at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:99)
at kotlinx.serialization.json.Json.encodeToString(Json.kt:125)
at de.mpmediasoft.teavmtest.Client$Companion.dispatch(Client.kt:68)
at de.mpmediasoft.teavmtest.Client.dispatch(-1)
at de.mpmediasoft.teavmtest.Client.dispatch$exported$1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateWasmGC'.
> Errors occurred during TeaVM build
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 3s
11:50:34: Execution finished 'build'.
The text was updated successfully, but these errors were encountered:
Although technically it's possible to implement such methods, practically this does not makes sense and makes life for everyone just worse. Instead, I usually just patch Kotlin runtime bytecode to avoid such calls. In the example all three missing methods are called from AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered, so I'd patch this method instead.
I am trying to convert some Kotlin code, which was written for the JVM and uses some Java libraries, to JavaScript (and if that works later to Wasm and C too). This code also uses Kotlin serialization (JSON) which I thought would be no problem because Kotlin serialization does not use reflection. But it turns out that this does not work because some standard Java methods are missing.
These are:
Is there any chance that these three missing methods could be implemented?
The full error output is:
The text was updated successfully, but these errors were encountered: