Fix compilation against JRE 9 on JPS
Write the modular JDK (9+) path to the module.xml file passed to the compiler from the JPS plugin. This path is then recorded in the compiler configuration in KotlinToJVMBytecodeCompiler.configureSourceRoots. This is needed because in JPS plugin, we pass "-no-jdk" and thus no JDK home path was recorded in the compiler configuration in K2JVMCompiler.setupJdkClasspathRoots. Presence of JDK home path in the configuration is crucial for JDK 9 support (see KotlinCoreEnvironment.Companion.createApplicationEnvironment), because classes there can only be loaded with the special "jrt" file system, not as .class files in .jar files #KT-17801 Fixed
This commit is contained in:
@@ -204,6 +204,16 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
for (module in chunk) {
|
||||
val modularJdkRoot = module.modularJdkRoot
|
||||
if (modularJdkRoot != null) {
|
||||
// We use the SDK of the first module in the chunk, which is not always correct because some other module in the chunk
|
||||
// might depend on a different SDK
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, File(modularJdkRoot))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
configuration.addAll(JVMConfigurationKeys.MODULES, chunk)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user