Skip to content

Commit

Permalink
Make embedKernel arguments nullable
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
fmagin authored and ileasile committed Mar 2, 2021
1 parent ea1382a commit 1578ab1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/org/jetbrains/kotlinx/jupyter/ikotlin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ fun main(vararg args: String) {
/**
* This function is to be run in projects which use kernel as a library,
* so we don't have a big need in covering it with tests
*
* The expected use case for this function is embedding into a Java application that doesn't necessarily support extensions written in Kotlin
* The signature of this function should thus be simple, and e.g. allow resolutionInfoProvider to be null instead of having to pass EmptyResolutionInfoProvider
* because EmptyResolutionInfoProvider is a Kotlin singleton object and it takes a while to understand how to use it from Java code.
*/
@Suppress("unused")
fun embedKernel(cfgFile: File, resolutionInfoProvider: ResolutionInfoProvider = EmptyResolutionInfoProvider, scriptReceivers: List<Any>? = null) {
fun embedKernel(cfgFile: File, resolutionInfoProvider: ResolutionInfoProvider?, scriptReceivers: List<Any>? = null) {
val cp = System.getProperty("java.class.path").split(File.pathSeparator).toTypedArray().map { File(it) }
val config = KernelConfig.fromConfig(
KernelJupyterParams.fromFile(cfgFile),
resolutionInfoProvider,
resolutionInfoProvider ?: EmptyResolutionInfoProvider,
cp,
null,
true
Expand Down

0 comments on commit 1578ab1

Please sign in to comment.