Fix execution of simple .kts scripts on Java 9
This commit is contained in:
+9
-3
@@ -331,9 +331,15 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
val state = analyzeAndGenerate(environment) ?: return null
|
val state = analyzeAndGenerate(environment) ?: return null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val classLoader = GeneratedClassLoader(state.factory, parentClassLoader ?: URLClassLoader(
|
val urls = environment.configuration.getList(JVMConfigurationKeys.CONTENT_ROOTS).mapNotNull { root ->
|
||||||
environment.configuration.jvmClasspathRoots.map { it.toURI().toURL() }.toTypedArray(), null
|
when (root) {
|
||||||
))
|
is JvmModulePathRoot -> root.file // TODO: only add required modules
|
||||||
|
is JvmClasspathRoot -> root.file
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}.map { it.toURI().toURL() }
|
||||||
|
|
||||||
|
val classLoader = GeneratedClassLoader(state.factory, parentClassLoader ?: URLClassLoader(urls.toTypedArray(), null))
|
||||||
|
|
||||||
val script = environment.getSourceFiles()[0].script ?: error("Script must be parsed")
|
val script = environment.getSourceFiles()[0].script ?: error("Script must be parsed")
|
||||||
return classLoader.loadClass(script.fqName.asString())
|
return classLoader.loadClass(script.fqName.asString())
|
||||||
|
|||||||
Reference in New Issue
Block a user