From dc4c8c40bf6d6168fbe9e83b574a7a8327494c9f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 30 Mar 2017 14:02:18 +0300 Subject: [PATCH] Fix Java6BuiltInsWithJDKMembersTest on Linux PathUtil.getJdkClassesRoots() takes the path to the JRE. On macOS, this is the same as the path to the JDK (for Java 6), so the test worked there. However for OpenJDK on Linux, there's a separate directory named "jre" in the JDK root. See JavaSdkUtil.getJdkClassesRoots for more information on how the JDK roots are found --- .../org/jetbrains/kotlin/test/KotlinTestUtils.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index 6ee9ec10ae1..f897993e3ae 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -459,7 +459,7 @@ public class KotlinTestUtils { JvmContentRootsKt.addJvmClasspathRoot(configuration, findAndroidApiJar()); } else if (jdkKind == TestJdkKind.FULL_JDK_6) { - JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots(System.getenv("JDK_16"))); + JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots(getJre6Home())); } else { JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots()); @@ -483,6 +483,15 @@ public class KotlinTestUtils { return configuration; } + @NotNull + private static String getJre6Home() { + String home = System.getenv("JDK_16"); + if (home == null) throw new AssertionError("Environment variable JDK_16 is not set"); + + File jre = new File(home, "jre"); + return jre.isDirectory() ? jre.getPath() : home; + } + public static void resolveAllKotlinFiles(KotlinCoreEnvironment environment) throws IOException { List paths = environment.getConfiguration().get(JVMConfigurationKeys.CONTENT_ROOTS); if (paths == null) return;