Add -Xuse-old-class-files-reading CLI argument
By default we use the fast implementation in CLI compiler, but in the most of the tests the old one is enabled Also add tests on CompiledJava with the fast class reading implementation
This commit is contained in:
@@ -123,7 +123,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
Assert.assertEquals("test", packageFromSource.getName().asString());
|
||||
|
||||
PackageViewDescriptor packageFromBinary = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot(
|
||||
tmpdir, getTestRootDisposable(), getJdkKind(), configurationKind, true
|
||||
tmpdir, getTestRootDisposable(), getJdkKind(), configurationKind, true, false
|
||||
).first;
|
||||
|
||||
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(packageFromBinary.getMemberScope())) {
|
||||
@@ -138,6 +138,10 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
compareDescriptors(packageFromSource, packageFromBinary, comparatorConfiguration, txtFile);
|
||||
}
|
||||
|
||||
protected boolean useFastClassFilesReading() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void doTestJavaAgainstKotlin(String expectedFileName) throws Exception {
|
||||
File expectedFile = new File(expectedFileName);
|
||||
File sourcesDir = new File(expectedFileName.replaceFirst("\\.txt$", ""));
|
||||
@@ -207,8 +211,8 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
FileUtil.copy(originalJavaFile, new File(testPackageDir, originalJavaFile.getName()));
|
||||
|
||||
Pair<PackageViewDescriptor, BindingContext> javaPackageAndContext = loadTestPackageAndBindingContextFromJavaRoot(
|
||||
tmpdir, getTestRootDisposable(), getJdkKind(), ConfigurationKind.JDK_ONLY, false
|
||||
);
|
||||
tmpdir, getTestRootDisposable(), getJdkKind(), ConfigurationKind.JDK_ONLY, false,
|
||||
false);
|
||||
|
||||
checkJavaPackage(
|
||||
expectedFile, javaPackageAndContext.first, javaPackageAndContext.second,
|
||||
@@ -253,7 +257,8 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
) throws IOException {
|
||||
compileJavaWithAnnotationsJar(javaFiles, outDir);
|
||||
return loadTestPackageAndBindingContextFromJavaRoot(outDir, myTestRootDisposable, getJdkKind(), configurationKind, true);
|
||||
return loadTestPackageAndBindingContextFromJavaRoot(outDir, myTestRootDisposable, getJdkKind(), configurationKind, true,
|
||||
useFastClassFilesReading());
|
||||
}
|
||||
|
||||
private static void checkJavaPackage(
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.kotlin.jvm.compiler
|
||||
|
||||
abstract class AbstractLoadJavaWithFastClassReadingTest : AbstractLoadJavaTest() {
|
||||
override fun useFastClassFilesReading() = true
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.codegen.GenerationUtils;
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
@@ -70,7 +71,8 @@ public class LoadDescriptorUtil {
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull TestJdkKind testJdkKind,
|
||||
@NotNull ConfigurationKind configurationKind,
|
||||
boolean isBinaryRoot
|
||||
boolean isBinaryRoot,
|
||||
boolean useFastClassReading
|
||||
) {
|
||||
List<File> javaBinaryRoots = new ArrayList<>();
|
||||
javaBinaryRoots.add(KotlinTestUtils.getAnnotationsJar());
|
||||
@@ -85,6 +87,7 @@ public class LoadDescriptorUtil {
|
||||
}
|
||||
CompilerConfiguration configuration =
|
||||
KotlinTestUtils.newConfiguration(configurationKind, testJdkKind, javaBinaryRoots, javaSourceRoots);
|
||||
configuration.put(JVMConfigurationKeys.USE_FAST_CLASS_FILES_READING, useFastClassReading);
|
||||
KotlinCoreEnvironment environment =
|
||||
KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdir() {
|
||||
}
|
||||
|
||||
val expected = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot(
|
||||
tmpdir, testRootDisposable, jdkKind, ConfigurationKind.ALL, true
|
||||
tmpdir, testRootDisposable, jdkKind, ConfigurationKind.ALL, true, false
|
||||
).first
|
||||
|
||||
RecursiveDescriptorComparator.validateAndCompareDescriptors(expected, actual, comparatorConfiguration, null)
|
||||
|
||||
Reference in New Issue
Block a user