Support compilation against modular JDK (9+)
For more information about the "jrt" file system, see http://openjdk.java.net/jeps/220 and https://bugs.openjdk.java.net/browse/JDK-8066492. This commit fixes DiagnosticsWithJdk9TestGenerated.testKt11167 #KT-11167 Fixed
This commit is contained in:
@@ -49,6 +49,10 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JvmContentRootsKt;
|
||||
@@ -428,6 +432,30 @@ public class KotlinTestUtils {
|
||||
public static CompilerConfiguration newConfiguration() {
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, TEST_MODULE_NAME);
|
||||
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, new MessageCollector() {
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(
|
||||
@NotNull CompilerMessageSeverity severity, @NotNull String message, @Nullable CompilerMessageLocation location
|
||||
) {
|
||||
if (severity == CompilerMessageSeverity.ERROR) {
|
||||
String prefix = location == null
|
||||
? ""
|
||||
: "(" + location.getPath() + ":" + location.getLine() + ":" + location.getColumn() + ") ";
|
||||
throw new AssertionError(prefix + message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasErrors() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@@ -466,7 +494,7 @@ public class KotlinTestUtils {
|
||||
else if (jdkKind == TestJdkKind.FULL_JDK_9) {
|
||||
String jdk9 = System.getenv("JDK_9");
|
||||
if (jdk9 != null) {
|
||||
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromJre(getJreHome(jdk9)));
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, new File(getJreHome(jdk9)));
|
||||
}
|
||||
else {
|
||||
System.err.println("Environment variable JDK_9 is not set, the test will be skipped");
|
||||
|
||||
Reference in New Issue
Block a user