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:
+5
-4
@@ -29,13 +29,14 @@ class ModuleBuilder(
|
||||
private val classpathRoots = ArrayList<String>()
|
||||
private val javaSourceRoots = ArrayList<JavaRootPath>()
|
||||
private val friendDirs = ArrayList<String>()
|
||||
override var modularJdkRoot: String? = null
|
||||
|
||||
fun addSourceFiles(pattern: String) {
|
||||
sourceFiles.add(pattern)
|
||||
fun addSourceFiles(path: String) {
|
||||
sourceFiles.add(path)
|
||||
}
|
||||
|
||||
fun addClasspathEntry(name: String) {
|
||||
classpathRoots.add(name)
|
||||
fun addClasspathEntry(path: String) {
|
||||
classpathRoots.add(path)
|
||||
}
|
||||
|
||||
fun addJavaSourceRoot(rootPath: JavaRootPath) {
|
||||
|
||||
+5
@@ -52,6 +52,7 @@ public class ModuleXmlParser {
|
||||
public static final String JAVA_SOURCE_PACKAGE_PREFIX = "packagePrefix";
|
||||
public static final String PATH = "path";
|
||||
public static final String CLASSPATH = "classpath";
|
||||
public static final String MODULAR_JDK_ROOT = "modularJdkRoot";
|
||||
|
||||
@NotNull
|
||||
public static ModuleScriptData parseModuleScript(
|
||||
@@ -172,6 +173,10 @@ public class ModuleXmlParser {
|
||||
String packagePrefix = getNullableAttribute(attributes, JAVA_SOURCE_PACKAGE_PREFIX);
|
||||
moduleBuilder.addJavaSourceRoot(new JavaRootPath(path, packagePrefix));
|
||||
}
|
||||
else if (MODULAR_JDK_ROOT.equalsIgnoreCase(qName)) {
|
||||
String path = getAttribute(attributes, PATH, qName);
|
||||
moduleBuilder.setModularJdkRoot(path);
|
||||
}
|
||||
else {
|
||||
throw createError(qName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user