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:
@@ -497,12 +497,9 @@ public class KotlinTestUtils {
|
||||
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromJre(getJreHome(jdk6)));
|
||||
}
|
||||
else if (jdkKind == TestJdkKind.FULL_JDK_9) {
|
||||
String jdk9 = System.getenv("JDK_19");
|
||||
if (jdk9 != null) {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, new File(jdk9));
|
||||
}
|
||||
else {
|
||||
System.err.println("Environment variable JDK_19 is not set, the test will be skipped");
|
||||
File home = getJre9HomeIfPossible();
|
||||
if (home != null) {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, home);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -527,6 +524,17 @@ public class KotlinTestUtils {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getJre9HomeIfPossible() {
|
||||
String jdk9 = System.getenv("JDK_19");
|
||||
if (jdk9 == null) {
|
||||
// TODO: replace this with a failure as soon as Java 9 is installed on all TeamCity agents
|
||||
System.err.println("Environment variable JDK_19 is not set, the test will be skipped");
|
||||
return null;
|
||||
}
|
||||
return new File(jdk9);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getJreHome(@NotNull String jdkHome) {
|
||||
File jre = new File(jdkHome, "jre");
|
||||
|
||||
Reference in New Issue
Block a user