diff --git a/compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt b/compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt index d2ffd39954d..19c3d4f5049 100644 --- a/compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt +++ b/compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt @@ -1,4 +1,5 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 + interface Test { fun test(p: T): T { return p @@ -18,4 +19,3 @@ fun execute(t: Test, p: T): T { fun box(): String { return execute(TestClass(), "O") } - diff --git a/compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt b/compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt index 2ef13a418a7..60ab59533fc 100644 --- a/compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt +++ b/compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt @@ -1,4 +1,5 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 + interface Test { fun test(p: T): T { return p @@ -21,4 +22,3 @@ fun execute(t: Test, p: T): T { fun box(): String { return execute(TestClass(), "O") } - diff --git a/compiler/testData/codegen/java8/box/jvm8/diamond.kt b/compiler/testData/codegen/java8/box/jvm8/diamond.kt index b9d638d2bd3..2b921508e3d 100644 --- a/compiler/testData/codegen/java8/box/jvm8/diamond.kt +++ b/compiler/testData/codegen/java8/box/jvm8/diamond.kt @@ -1,6 +1,7 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 // WITH_REFLECT // FULL_JDK + interface Test { fun test(): String { return "Test" @@ -30,6 +31,7 @@ class TestClass2 : TestClass(), Test3 { fun box(): String { val test = TestClass2().test() if (test != "Test2") return "fail 1: $test" + // TODO: enable this test once the required behavior is specified // checkNoMethod(TestClass::class.java, "test") // checkNoMethod(Test3::class.java, "test") // checkNoMethod(TestClass2::class.java, "test") @@ -44,5 +46,5 @@ fun checkNoMethod(clazz: Class<*>, name: String) { catch (e: NoSuchMethodException) { return } - throw java.lang.AssertionError("fail " + clazz) -} \ No newline at end of file + throw AssertionError("fail " + clazz) +} diff --git a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInClass.kt b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInClass.kt index 9320788869a..49b069cd786 100644 --- a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInClass.kt +++ b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInClass.kt @@ -1,4 +1,4 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK interface Test { @@ -11,6 +11,7 @@ class TestClass : Test { } fun box(): String { + // TODO: enable this test once the required behavior is specified // try { // TestClass::class.java.getDeclaredMethod("test") // } @@ -19,4 +20,4 @@ fun box(): String { // } // return "fail" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface.kt b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface.kt index 7828d579bb8..0fb65ae3445 100644 --- a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface.kt +++ b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface.kt @@ -1,4 +1,4 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK interface Test { @@ -11,6 +11,7 @@ interface Test2 : Test { } fun box(): String { + // TODO: enable this test once the required behavior is specified // try { // Test2::class.java.getDeclaredMethod("test") // } @@ -19,4 +20,4 @@ fun box(): String { // } // return "fail" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface2.kt b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface2.kt index c8481d01b26..13f6048127d 100644 --- a/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface2.kt +++ b/compiler/testData/codegen/java8/box/jvm8/noDelegation/noDelegationToDefaultMethodInInterface2.kt @@ -1,6 +1,7 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK + interface Test { fun test() { } @@ -15,6 +16,7 @@ interface Test3 : Test2 { } fun box(): String { + // TODO: enable this test once the required behavior is specified // try { // Test3::class.java.getDeclaredMethod("test") // } @@ -23,4 +25,4 @@ fun box(): String { // } // return "fail" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/box/jvm8/simpleCall.kt b/compiler/testData/codegen/java8/box/jvm8/simpleCall.kt index e2015b39958..33575361a09 100644 --- a/compiler/testData/codegen/java8/box/jvm8/simpleCall.kt +++ b/compiler/testData/codegen/java8/box/jvm8/simpleCall.kt @@ -1,4 +1,5 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 + interface Test { fun test(): String { return "OK" @@ -11,4 +12,4 @@ class TestClass : Test { fun box(): String { return TestClass().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt index fab0b7fc8fc..fec660b49cb 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInClass.kt @@ -8,7 +8,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 class TestClass : Test { } @@ -21,4 +21,4 @@ fun box(): String { return "fail" } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt index 1b1f7fa86d5..6df0806ed97 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface.kt @@ -8,7 +8,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 interface Test2 : Test { } @@ -21,4 +21,4 @@ fun box(): String { return "fail" } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt index 32eafa4010c..c61b623d1e4 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/delegationToDefaultMethodInInterface2.kt @@ -9,7 +9,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 interface Test2 : Test { } @@ -21,6 +21,7 @@ class TestClass : Test3 fun box(): String { checkPresent(Test2::class.java, "test") + // TODO: enable this test once the required behavior is specified // checkNoMethod(Test3::class.java, "test") return TestClass().test() @@ -44,4 +45,4 @@ fun checkPresent(clazz: Class<*>, name: String) { throw java.lang.AssertionError("Method $name doesn't exist in $clazz") } return -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond.kt index a6beb77c3ea..fe14b4a46cb 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond.kt @@ -9,7 +9,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 interface Test2 : Test { } @@ -31,6 +31,7 @@ class TestClass : Test4 { fun box(): String { checkPresent(Test2::class.java, "test") checkPresent(Test3::class.java, "test") + // TODO: enable this test once the required behavior is specified //checkNoMethod(Test4::class.java, "test") return TestClass().test() @@ -53,4 +54,4 @@ fun checkPresent(clazz: Class<*>, name: String) { throw java.lang.AssertionError("Method $name doesn't exist in $clazz") } return -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond2.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond2.kt index 1c4758561e0..88369d0c923 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond2.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond2.kt @@ -9,7 +9,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 open class TestClass : Test { } @@ -47,4 +47,4 @@ fun checkPresent(clazz: Class<*>, name: String) { throw java.lang.AssertionError("Method $name doesn't exist in $clazz") } return -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond3.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond3.kt index c0aadd28cd9..be4b052e35b 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond3.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/delegation/diamond3.kt @@ -9,7 +9,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 open class TestClass : Test { } @@ -49,4 +49,4 @@ fun checkPresent(clazz: Class<*>, name: String) { throw java.lang.AssertionError("Method $name doesn't exist in $clazz") } return -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt index 468393c21d5..b34afdc269c 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCall.kt @@ -7,11 +7,11 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 class TestClass : Test { } fun box(): String { return TestClass().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt index accdbb68080..85d5c83c5c1 100644 --- a/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt +++ b/compiler/testData/codegen/java8/compileKotlinAgainstKotlin/jvm8against6/simpleCallWithHierarchy.kt @@ -7,7 +7,7 @@ interface Test { } // FILE: 2.kt -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 interface Test2 : Test { } @@ -19,4 +19,4 @@ class TestClass : Test2 { fun box(): String { return TestClass().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/java8/writeFlags/defaultMethod.kt b/compiler/testData/codegen/java8/writeFlags/defaultMethod.kt index 2458a71330b..aa5b4b37b2a 100644 --- a/compiler/testData/codegen/java8/writeFlags/defaultMethod.kt +++ b/compiler/testData/codegen/java8/writeFlags/defaultMethod.kt @@ -1,4 +1,5 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 + interface Test { fun test(): String { return "OK" @@ -13,4 +14,4 @@ interface Test { // TESTED_OBJECT_KIND: function // TESTED_OBJECTS: Test, testAbstract -// FLAGS: ACC_PUBLIC, ACC_ABSTRACT \ No newline at end of file +// FLAGS: ACC_PUBLIC, ACC_ABSTRACT diff --git a/compiler/testData/codegen/java8/writeFlags/interfaceAndDefaultImpls.kt b/compiler/testData/codegen/java8/writeFlags/interfaceAndDefaultImpls.kt index 3e38b83e06a..0190c13df2d 100644 --- a/compiler/testData/codegen/java8/writeFlags/interfaceAndDefaultImpls.kt +++ b/compiler/testData/codegen/java8/writeFlags/interfaceAndDefaultImpls.kt @@ -1,4 +1,5 @@ -// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM_8_TARGET +// JVM_TARGET: 1.8 + interface Test { fun a() { @@ -9,7 +10,6 @@ interface Test { // TESTED_OBJECTS: Test$DefaultImpls // FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_SUPER - // TESTED_OBJECT_KIND: class // TESTED_OBJECTS: Test // FLAGS: ACC_PUBLIC, ACC_ABSTRACT, ACC_INTERFACE diff --git a/compiler/tests-common/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/org/jetbrains/kotlin/codegen/CodegenTestCase.java index 0e1233c0a0e..b3d9c996f5f 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; import com.intellij.testFramework.TestDataFile; import kotlin.collections.ArraysKt; +import kotlin.collections.CollectionsKt; import kotlin.io.FilesKt; import kotlin.text.Charsets; import org.jetbrains.annotations.NotNull; @@ -38,6 +39,7 @@ import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime; import org.jetbrains.kotlin.config.CompilerConfiguration; import org.jetbrains.kotlin.config.CompilerConfigurationKey; import org.jetbrains.kotlin.config.JVMConfigurationKeys; +import org.jetbrains.kotlin.config.JvmTarget; import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtFile; @@ -146,6 +148,14 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { List kotlinConfigurationFlags = new ArrayList(0); for (TestFile testFile : testFilesWithConfigurationDirectives) { kotlinConfigurationFlags.addAll(InTextDirectivesUtils.findListWithPrefixes(testFile.content, "// KOTLIN_CONFIGURATION_FLAGS:")); + + List lines = InTextDirectivesUtils.findLinesWithPrefixesRemoved(testFile.content, "// JVM_TARGET:"); + if (!lines.isEmpty()) { + String targetString = CollectionsKt.single(lines); + JvmTarget jvmTarget = JvmTarget.Companion.fromString(targetString); + assert jvmTarget != null : "Unknown target: " + targetString; + configuration.put(JVMConfigurationKeys.JVM_TARGET, jvmTarget); + } } updateConfigurationWithFlags(configuration, kotlinConfigurationFlags);