Abstract script compiled module implementation used in saving/caching

removes classloading problem when main-kts is loaded from a CL
without scripting compiler.
Also relax dependencies collection on saving to a jar and hide redundant
logging.
Running main.kts script via a run configuration works now.
#KT-37765 fixed
This commit is contained in:
Ilya Chernikov
2020-04-01 14:14:18 +02:00
parent 278f77713d
commit c64ba50655
6 changed files with 14 additions and 13 deletions
@@ -6,9 +6,9 @@
package org.jetbrains.kotlin.scripting.compiler.plugin.impl
import java.io.Serializable
import kotlin.script.experimental.jvm.impl.KJvmCompiledModule
import kotlin.script.experimental.jvm.impl.KJvmCompiledModuleInMemory
class KJvmCompiledModuleInMemory(val compilerOutputFiles: Map<String, ByteArray>) : KJvmCompiledModule,
class KJvmCompiledModuleInMemoryImpl(override val compilerOutputFiles: Map<String, ByteArray>) : KJvmCompiledModuleInMemory,
Serializable {
override fun createClassLoader(baseClassLoader: ClassLoader?): ClassLoader =
@@ -28,7 +28,7 @@ import kotlin.script.experimental.host.getMergedScriptText
import kotlin.script.experimental.jvm.impl.KJvmCompiledScript
internal fun makeCompiledModule(generationState: GenerationState) =
KJvmCompiledModuleInMemory(
KJvmCompiledModuleInMemoryImpl(
generationState.factory.asList()
.associateTo(sortedMapOf<String, ByteArray>()) { it.relativePath to it.asByteArray() }
)