Skip to content

Commit a94e713

Browse files
authored
Make embedKernel arguments nullable
EmptyResolutionInfoProvider is created by an [object declaration](https://kotlinlang.org/docs/object-declarations.html#object-declarations) which fails to import in pure java code. The `embedKernel` method is intended to be called inside pure Java code that simply has the compiled kotlin kernel jars available as a dependency, but the former signature after the refactor in 782f088#diff-3c1c4b1ddbb3338fe28601f266bb3c492ac38a395dafb1c3ad4b60a8ffeedc62R85 makes this impossible. This commit makes the `resolutionInfoProvider` nullable again, which also means that existing code using the method and passing null, still works with the the signature using `ResolutionInfoProvider`
1 parent d42c87a commit a94e713

File tree

1 file changed

+6
-2
lines changed
  • src/main/kotlin/org/jetbrains/kotlinx/jupyter

1 file changed

+6
-2
lines changed

src/main/kotlin/org/jetbrains/kotlinx/jupyter/ikotlin.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,17 @@ fun main(vararg args: String) {
8080
/**
8181
* This function is to be run in projects which use kernel as a library,
8282
* so we don't have a big need in covering it with tests
83+
*
84+
* The expected use case for this function is embedding into a Java application that doesn't necessarily support extensions written in Kotlin
85+
* The signature of this function should thus be simple, and e.g. allow resolutionInfoProvider to be null instead of having to pass EmptyResolutionInfoProvider
86+
* because EmptyResolutionInfoProvider is a Kotlin singleton object and cannot be imported in Java code.
8387
*/
8488
@Suppress("unused")
85-
fun embedKernel(cfgFile: File, resolutionInfoProvider: ResolutionInfoProvider = EmptyResolutionInfoProvider, scriptReceivers: List<Any>? = null) {
89+
fun embedKernel(cfgFile: File, resolutionInfoProvider: ResolutionInfoProvider?, scriptReceivers: List<Any>? = null) {
8690
val cp = System.getProperty("java.class.path").split(File.pathSeparator).toTypedArray().map { File(it) }
8791
val config = KernelConfig.fromConfig(
8892
KernelJupyterParams.fromFile(cfgFile),
89-
resolutionInfoProvider,
93+
resolutionInfoProvider ?: EmptyResolutionInfoProvider,
9094
cp,
9195
null,
9296
true

0 commit comments

Comments
 (0)