Add jdk jars to kotlin classpath
#KT-4214 Fixed
This commit is contained in:
@@ -344,7 +344,12 @@ public class JetTestUtils {
|
||||
@NotNull TestJdkKind jdkKind, @NotNull Collection<File> extraClasspath, @NotNull Collection<File> priorityClasspath) {
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
configuration.addAll(CLASSPATH_KEY, priorityClasspath);
|
||||
configuration.add(CLASSPATH_KEY, jdkKind == TestJdkKind.MOCK_JDK ? findMockJdkRtJar() : PathUtil.findRtJar());
|
||||
if (jdkKind == TestJdkKind.MOCK_JDK) {
|
||||
configuration.add(CLASSPATH_KEY, findMockJdkRtJar());
|
||||
}
|
||||
else {
|
||||
configuration.addAll(CLASSPATH_KEY, PathUtil.getJdkClassesRoots());
|
||||
}
|
||||
if (configurationKind == ALL) {
|
||||
configuration.add(CLASSPATH_KEY, ForTestCompileRuntime.runtimeJarForTests());
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cli/jvm"), Pattern.compile("^(.+)\\.args$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("classpath.args")
|
||||
public void testClasspath() throws Exception {
|
||||
doJvmTest("compiler/testData/cli/jvm/classpath.args");
|
||||
}
|
||||
|
||||
@TestMetadata("diagnosticsOrder.args")
|
||||
public void testDiagnosticsOrder() throws Exception {
|
||||
doJvmTest("compiler/testData/cli/jvm/diagnosticsOrder.args");
|
||||
|
||||
+5
@@ -480,6 +480,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib/fullJdk"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("classpath.kt")
|
||||
public void testClasspath() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/fullJdk/classpath.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericBackingFieldSignature.kt")
|
||||
public void testGenericBackingFieldSignature() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/fullJdk/genericBackingFieldSignature.kt");
|
||||
|
||||
+14
-3
@@ -113,7 +113,7 @@ public class ResolveDescriptorsFromExternalLibraries {
|
||||
System.out.println("Using file " + jar);
|
||||
}
|
||||
else {
|
||||
jar = PathUtil.findRtJar();
|
||||
jar = findRtJar();
|
||||
System.out.println("Using rt.jar: " + jar);
|
||||
}
|
||||
|
||||
@@ -138,6 +138,17 @@ public class ResolveDescriptorsFromExternalLibraries {
|
||||
return hasErrors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static File findRtJar() {
|
||||
List<File> roots = PathUtil.getJdkClassesRoots();
|
||||
for (File root : roots) {
|
||||
if (root.getName().equals("rt.jar") || root.getName().equals("classes.jar")) {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No rt.jar/classes.jar found under " + System.getProperty("java.home"));
|
||||
}
|
||||
|
||||
private boolean parseLibraryFileChunk(File jar, String libDescription, ZipInputStream zip, int classesPerChunk) throws IOException {
|
||||
Disposable junk = new Disposable() {
|
||||
@Override
|
||||
@@ -153,8 +164,8 @@ public class ResolveDescriptorsFromExternalLibraries {
|
||||
CompilerConfiguration configuration =
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK);
|
||||
jetCoreEnvironment = JetCoreEnvironment.createForTests(junk, configuration);
|
||||
if (!PathUtil.findRtJar().equals(jar)) {
|
||||
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + PathUtil.findRtJar());
|
||||
if (!findRtJar().equals(jar)) {
|
||||
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + findRtJar());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user