Use JDK annotations downloaded from a KAnnotator build

This commit is contained in:
Andrey Breslav
2014-02-14 21:17:03 +04:00
parent 48df541e0f
commit ff762a4467
180 changed files with 31 additions and 35784 deletions
@@ -17,13 +17,12 @@
package org.jetbrains.jet;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.junit.Test;
public class CompileCompilerDependenciesTest {
@Test
public void packJdkAnnotations() {
ForTestPackJdkAnnotations.jdkAnnotationsForTests();
JetTestUtils.getJdkAnnotationsJar();
}
@Test
@@ -47,7 +47,6 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.jetbrains.jet.config.CommonConfigurationKeys;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
@@ -272,6 +271,15 @@ public class JetTestUtils {
return new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK/jre/lib/annotations.jar");
}
@NotNull
public static File getJdkAnnotationsJar() {
File jdkAnnotations = new File("dependencies/annotations/kotlin-jdk-annotations.jar");
if (!jdkAnnotations.exists()) {
throw new RuntimeException("Kotlin JDK annotations jar not found; please run 'ant dist' to build it");
}
return jdkAnnotations;
}
public static void mkdirs(File file) throws IOException {
if (file.isDirectory()) {
return;
@@ -370,7 +378,7 @@ public class JetTestUtils {
configuration.addAll(CLASSPATH_KEY, extraClasspath);
if (configurationKind == ALL || configurationKind == JDK_AND_ANNOTATIONS) {
configuration.add(ANNOTATIONS_PATH_KEY, ForTestPackJdkAnnotations.jdkAnnotationsForTests());
configuration.add(ANNOTATIONS_PATH_KEY, getJdkAnnotationsJar());
}
return configuration;
@@ -91,7 +91,7 @@ public class ForTestCompileRuntime {
"-noStdlib",
"-noJdkAnnotations",
"-suppress", "warnings",
"-annotations", "./jdk-annotations",
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
"-classpath", classPath
);
if (exitCode != ExitCode.OK) {
@@ -1,72 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen.forTestCompile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.jar.JarOutputStream;
public class ForTestPackJdkAnnotations {
private ForTestPackJdkAnnotations() {
}
private static File jarFile = null;
private static File getJarFile() {
if (jarFile == null) {
try {
File tmpDir = JetTestUtils.tmpDir("test_jars");
jarFile = new File(tmpDir, "jdk-annotations.jar");
FileOutputStream annotationsJar = new FileOutputStream(jarFile);
try {
JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(annotationsJar));
try {
ForTestCompileSomething.copyToJar(new File("./jdk-annotations"), jarOutputStream);
}
finally {
jarOutputStream.close();
}
}
finally {
annotationsJar.close();
}
}
catch (IOException e) {
throw new AssertionError(e);
}
}
return jarFile;
}
@NotNull
public static File jdkAnnotationsForTests() {
if (ForTestCompileSomething.ACTUALLY_COMPILE) {
return getJarFile();
}
File jdkAnnotations = new File("dist/kotlinc/lib/kotlin-jdk-annotations.jar");
if (!jdkAnnotations.exists()) {
throw new RuntimeException("Kotlin JDK annotations jar not found; please run 'ant dist' to build it");
}
return jdkAnnotations;
}
}
@@ -19,9 +19,9 @@ package org.jetbrains.jet.jvm.compiler;
import com.intellij.openapi.util.io.FileUtil;
import junit.framework.TestCase;
import org.jetbrains.jet.JetTestCaseBuilder;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
@@ -42,7 +42,7 @@ public class CompileEnvironmentTest extends TestCase {
try {
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar();
File resultJar = new File(tempDir, "result.jar");
ExitCode rv = new K2JVMCompiler().exec(System.out,
"-module", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kts",
@@ -78,7 +78,7 @@ public class CompileEnvironmentTest extends TestCase {
try {
File out = new File(tempDir, "out");
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar();
ExitCode exitCode = new K2JVMCompiler()
.exec(System.out, "-src", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kt",
"-output", out.getAbsolutePath(),
@@ -49,7 +49,7 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
@Override
protected void setUp() throws Exception {
super.setUp();
kotlinAnnotationsRoot = VirtualFileManager.getInstance().findFileByUrl("file://jdk-annotations");
kotlinAnnotationsRoot = VirtualFileManager.getInstance().findFileByUrl("jar://dependencies/annotations/kotlin-jdk-annotations.jar!/");
ideaAnnotationsRoot = VirtualFileManager.getInstance().findFileByUrl("jar://ideaSDK/lib/jdkAnnotations.jar!/");
}
@@ -101,7 +101,7 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
}
public void testNoErrorsInAlternativeSignatures() {
List<FqName> affectedClasses = getAffectedClasses("file://jdk-annotations");
List<FqName> affectedClasses = getAffectedClasses("jar://dependencies/annotations/kotlin-jdk-annotations.jar!/");
Map<String, List<String>> errors = Maps.newLinkedHashMap();