Unable to upgrade past 0.11.0-125
breandan opened this issue · 6 comments
I recently tried updating from 0.11.0-125 to 0.11.0-134, however compilation failed after doing so with the following error:
Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
In order to resolve it, I added the following snippet to my build.gradle.kts file:
kotlin {
jvm {
compilations.all {
kotlinOptions {
kotlinOptions.jvmTarget = "11"
}
}
}
}
This compiled, but subsequently produced the following error when running ./gradlew allTests:
RenderingTests[jvm] > random matrix is rendered to bmp()[jvm] FAILED
org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException: The problem is found in one of the loaded libraries: check library imports, dependencies and repositories
at app//org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:29)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.addLibraries(CellExecutorImpl.kt:145)
at app//org.jetbrains.kotlinx.jupyter.libraries.LibrariesScanner.addLibrariesFromClassLoader(LibrariesScanner.kt:59)
at app//org.jetbrains.kotlinx.jupyter.libraries.LibrariesScanner.addLibrariesFromClassLoader$default(LibrariesScanner.kt:49)
at app//org.jetbrains.kotlinx.jupyter.testkit.ReplProvider$Companion$initializeWithCurrentClasspath$1.invoke(ReplProvider.kt:49)
at app//org.jetbrains.kotlinx.jupyter.testkit.ReplProvider$Companion$initializeWithCurrentClasspath$1.invoke(ReplProvider.kt:49)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:119)
at app//org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.eval(repl.kt:490)
at app//org.jetbrains.kotlinx.jupyter.testkit.ReplProvider$Companion.initializeWithCurrentClasspath(ReplProvider.kt:49)
at app//org.jetbrains.kotlinx.jupyter.testkit.ReplProvider$Companion.withoutLibraryResolution$lambda-1(ReplProvider.kt:17)
at app//org.jetbrains.kotlinx.jupyter.testkit.JupyterReplTestCase.<init>(JupyterReplTestCase.kt:15)
at app//org.jetbrains.kotlinx.jupyter.testkit.JupyterReplTestCase.<init>(JupyterReplTestCase.kt:12)
at app//ai.hypergraph.kaliningraph.notebook.RenderingTests.<init>(NotebookTest.kt:11)
Caused by:
org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException: Unable to initialize repl compiler:
DEBUG Using JVM IR backend
ERROR MainCommandLineProcessor::pluginOptions accessed before thread local parameters have been set: java.lang.IllegalStateException: MainCommandLineProcessor::pluginOptions accessed before thread local parameters have been set
at app//org.jetbrains.kotlinx.jupyter.repl.impl.JupyterCompilerImpl.compileSync(JupyterCompilerImpl.kt:174)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:99)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:71)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:69)
at app//org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withHost(repl.kt:635)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:69)
at app//org.jetbrains.kotlinx.jupyter.repl.CellExecutor$DefaultImpls.execute$default(CellExecutor.kt:15)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.execute(CellExecutorImpl.kt:204)
at app//org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution$toExecutionCallback$1.invoke(CodeExecution.kt:20)
at app//org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution$toExecutionCallback$1.invoke(CodeExecution.kt:16)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.execute(CellExecutorImpl.kt:226)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.runChild(CellExecutorImpl.kt:136)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.runChild(CellExecutorImpl.kt:132)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext.access$runChild(CellExecutorImpl.kt:122)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext$addLibraries$1.invoke(CellExecutorImpl.kt:146)
at app//org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$ExecutionContext$addLibraries$1.invoke(CellExecutorImpl.kt:145)
at app//org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryExceptionKt.rethrowAsLibraryException(ReplLibraryException.kt:27)
... 12 more
Caused by:
java.lang.IllegalStateException: Unable to initialize repl compiler:
DEBUG Using JVM IR backend
ERROR MainCommandLineProcessor::pluginOptions accessed before thread local parameters have been set: java.lang.IllegalStateException: MainCommandLineProcessor::pluginOptions accessed before thread local parameters have been set
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.KJvmReplCompilerBase$Companion.createCompilationState(KJvmReplCompilerBase.kt:337)
at org.jetbrains.kotlin.scripting.ide_services.compiler.KJvmReplCompilerWithIdeServices$1.invoke(KJvmReplCompilerWithIdeServices.kt:30)
at org.jetbrains.kotlin.scripting.ide_services.compiler.KJvmReplCompilerWithIdeServices$1.invoke(KJvmReplCompilerWithIdeServices.kt:29)
at org.jetbrains.kotlin.scripting.compiler.plugin.repl.JvmReplCompilerState.initializeCompilation(jvmReplCompilation.kt:61)
at org.jetbrains.kotlin.scripting.compiler.plugin.repl.JvmReplCompilerState.getCompilationState(jvmReplCompilation.kt:47)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.KJvmReplCompilerBase.compile$suspendImpl(KJvmReplCompilerBase.kt:74)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.KJvmReplCompilerBase.compile(KJvmReplCompilerBase.kt)
at kotlin.script.experimental.api.ReplCompiler$DefaultImpls.compile(replCompilation.kt:49)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.KJvmReplCompilerBase.compile(KJvmReplCompilerBase.kt:54)
at org.jetbrains.kotlinx.jupyter.repl.impl.JupyterCompilerImpl$compileSync$resultWithDiagnostics$1.invokeSuspend(JupyterCompilerImpl.kt:173)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at org.jetbrains.kotlinx.jupyter.repl.impl.JupyterCompilerImpl.compileSync(JupyterCompilerImpl.kt:173)
... 28 more
After encountering this error, I decided to add the following line to the build.gradle.kts file:
jvm {
compilations.all {
kotlinOptions {
kotlinOptions.jvmTarget = "11"
useOldBackend = true
}
}
}
However I then encountered the following issue:
w: Language version is automatically inferred to 1.5 when using the old JVM backend. Consider specifying -language-version explicitly, or remove -Xuse-old-backend
This resulted in the second error reappearing. Currently it is unclear how to proceed, any advice would be appreciated.
Hi! Yes, upgrading JVM target is the expected step, because I've updated JVM target for the library.
The exception in test is odd, but I suppose that it's because of different versions of kotlin-compiler-embeddable on classpath:

1.8.xx is from Jupyter API testkit, 1.7.10 is probably from your dependencies. They're conflicting and create this effect. I either can try to release the version which depends on 1.7.10, or you may try to get rid of this dependency.
I think org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10 is a transitive dependency from KSP which conflicts with the KSP library integration method. I found KSP is also inherited from some standard Kotlin dependencies, I found this dependency tree from ./gradlew dependencies (IDK why org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10 depends on the 1.6.0 branch of KSP...):
kotlinCompilerPluginClasspathJvmMain - Kotlin compiler plugins for compilation 'main' (target jvm (jvm))
+--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10
| +--- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10
| | +--- org.jetbrains.kotlin:kotlin-scripting-common:1.7.10
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10
| | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10
| | | \--- org.jetbrains:annotations:13.0
| | +--- org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10
| | | +--- org.jetbrains.kotlin:kotlin-script-runtime:1.7.10
| | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 (*)
| | | \--- org.jetbrains.kotlin:kotlin-scripting-common:1.7.10 (*)
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 (*)
\--- com.google.devtools.ksp:symbol-processing:1.6.0-1.0.2
+--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
+--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.0
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
| +--- org.jetbrains.kotlin:kotlin-script-runtime:1.6.0 -> 1.7.10
| +--- org.jetbrains.kotlin:kotlin-reflect:1.6.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
| +--- org.jetbrains.kotlin:kotlin-daemon-embeddable:1.6.0
| +--- org.jetbrains.intellij.deps:trove4j:1.0.20181211
| \--- net.java.dev.jna:jna:5.6.0
\--- com.google.devtools.ksp:symbol-processing-api:1.6.0-1.0.2
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0
+--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
I released a version that depends only on stable Kotlin 1.7.10, but it didn't resolve the problem.
Then, I commented the following line in your build script:
https://github.com/breandan/galoisenne/blob/88bc47a098ac3731d6c4b7cc72714055a167180a/build.gradle.kts#L198
And test passed. Exception actually arises in this compiler testing plugin, in this line:
https://github.com/tschuchortdev/kotlin-compile-testing/blob/e45b94f8be546da692ba9c21fc09218fcbc15cbe/core/src/main/kotlin/com/tschuchort/compiletesting/MainCommandLineProcessor.kt#L16
So maybe you should report this problem in https://github.com/tschuchortdev/kotlin-compile-testing/issues/new
Hi Illya, thank you very much for investigating. I tried updating to 0.11.0-136-1 and commenting out the kotlin-compile-testing dependency as you suggested, however this produced a Gradle internal error and I was unable to trace it back to the mentioned dependency or get the tests to pass. Tangentially, I did report a previous issue (tschuchortdev/kotlin-compile-testing#300) with that very library, however I believe it is related to updating to JVM 11.
It's not an internal error, it's just a compilation error (see the last Caused by). If you haven't commented out the tests that use kotlin-compile-testing plugin, it's expected.
I filed another issue there: tschuchortdev/kotlin-compile-testing#301