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:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.checkers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,8 +44,8 @@ public abstract class AbstractDiagnosticsWithJdk9Test extends AbstractDiagnostic
|
||||
@NotNull Map<String, ModuleAndDependencies> modules,
|
||||
@NotNull List<TestFile> testFiles
|
||||
) {
|
||||
if (System.getenv("JDK_19") == null) {
|
||||
// Skip this test if no environment variable JDK_19 is set up
|
||||
if (KotlinTestUtils.getJre9HomeIfPossible() == null) {
|
||||
// Skip this test if no Java 9 is found
|
||||
return;
|
||||
}
|
||||
super.doMultiFileTest(file, modules, testFiles);
|
||||
|
||||
Reference in New Issue
Block a user