org.jetbrains.kotlinx.jupyter.util.ClassLoading.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-api Show documentation
Show all versions of kotlin-jupyter-api Show documentation
API for libraries supporting Kotlin Jupyter notebooks
package org.jetbrains.kotlinx.jupyter.util
val kernelFqnPrefixes =
listOf(
"kotlin.",
"org.jetbrains.kotlin.",
"jupyter.kotlin.",
"org.jetbrains.kotlinx.jupyter.api.",
"kotlinx.serialization.",
)
fun createDefaultDelegatingClassLoader(parent: ClassLoader): ClassLoader {
val strategy =
ClassLoadingDelegatingStrategy { classFqn: String, parentLoader: ClassLoader ->
val shouldLoadFromKernelClassLoader = kernelFqnPrefixes.any { classFqn.startsWith(it) }
if (shouldLoadFromKernelClassLoader) {
parentLoader
} else {
parentLoader.parent
}
}
return DelegatingClassLoader(parent, strategy)
}