diff --git a/compiler/android-tests/android-module/build.gradle b/compiler/android-tests/android-module/build.gradle index f3a75c5e2f4..979124f4231 100644 --- a/compiler/android-tests/android-module/build.gradle +++ b/compiler/android-tests/android-module/build.gradle @@ -1,5 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - +ext { + isD8Enabled = project.findProperty('android.enableD8').toBoolean() +} buildscript { repositories { google() @@ -58,6 +60,12 @@ android { resultsDir = "build/test/results" } + if (isD8Enabled) { + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } + } flavorDimensions "box" @@ -77,6 +85,17 @@ android { reflect0 { dimension "box" } + + + if (isD8Enabled) { + jvm80 { + dimension "box" + } + + reflectjvm80 { + dimension "box" + } + } } } diff --git a/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt b/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt index 30528f84971..a756070555f 100644 --- a/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt +++ b/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt @@ -102,7 +102,7 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P testCases.forEach { aCase -> suite.addTest(aCase) } Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong()) } - } catch (e: Exception) { + } catch (e: Throwable) { throw RuntimeException("Can't parse test results in $reportFolder\n$resultOutput", e) } } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt index 18e8eb0862b..e163e540e53 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt @@ -276,11 +276,13 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager if (fullFileText.contains("@file:JvmPackageName(")) continue // TODO: Support jvm assertions if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue + val targets = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fullFileText, "// JVM_TARGET:") + .also { it.remove(JvmTarget.JVM_1_6.description) } - // TODO: support JVM 8 test with D8 - if (fullFileText.contains("// JVM_TARGET")) continue - - val isJvm8Target = false + val isJvm8Target = + if (targets.isEmpty()) false + else if (targets.contains(JvmTarget.JVM_1_8.description) && targets.size == 1) true + else continue //TODO: support other targets on Android // TODO: support SKIP_JDK6 on new platforms if (fullFileText.contains("// SKIP_JDK6")) continue diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt index 58286be5175..c3c1c184061 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt @@ -1,6 +1,7 @@ // KOTLIN_CONFIGURATION_FLAGS: +JVM.EMIT_JVM_TYPE_ANNOTATIONS // TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_REFLECT // FULL_JDK diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/typeAnnotationTarget6.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/typeAnnotationTarget6.kt index 210ecc47e38..0fa0a911574 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/typeAnnotationTarget6.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/typeAnnotationTarget6.kt @@ -1,6 +1,10 @@ // KOTLIN_CONFIGURATION_FLAGS: +JVM.EMIT_JVM_TYPE_ANNOTATIONS // TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR + +// No virtual method getAnnotatedReturnType()Ljava/lang/reflect/AnnotatedType +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT // FULL_JDK // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/jdk/stream.kt b/compiler/testData/codegen/box/jdk/stream.kt index 1e4162cbb2e..94185022038 100644 --- a/compiler/testData/codegen/box/jdk/stream.kt +++ b/compiler/testData/codegen/box/jdk/stream.kt @@ -1,6 +1,10 @@ // IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM + +// NoSuchMethodError: java.util.List.stream +// IGNORE_BACKEND: ANDROID + // FULL_JDK // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt index 06d1afc812b..30aab3e3add 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt index b1b77bd609c..0f3dff031ef 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterface2.kt b/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterface2.kt index d44d22c6385..f7ec9bdd9a8 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterface2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterface2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: enable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterfaceWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterfaceWithProperties2.kt index b471b5682fa..efb2e27849c 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterfaceWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/bridgeInInterfaceWithProperties2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: enable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/diamond.kt b/compiler/testData/codegen/box/jvm8/defaults/diamond.kt index 0ef7d0a8598..a82f852c44f 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/diamond.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/diamond.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: enable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_REFLECT // FULL_JDK @@ -50,5 +51,5 @@ fun checkNoMethod(clazz: Class<*>, name: String) { catch (e: NoSuchMethodException) { return } - throw AssertionError("fail " + clazz) + throw AssertionError("fail: method $name was found in " + clazz) } diff --git a/compiler/testData/codegen/box/jvm8/defaults/kt11969.kt b/compiler/testData/codegen/box/jvm8/defaults/kt11969.kt index b443e426417..b781c55ed60 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/kt11969.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/kt11969.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: enable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt index 6f11cb93485..9f804de9f29 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: all // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt index a894eda2981..5b8140f5bc6 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: all // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDelegation/noDelegationToDefaultMethodInClass.kt b/compiler/testData/codegen/box/jvm8/defaults/noDelegation/noDelegationToDefaultMethodInClass.kt index 4c71cc93760..02f0eaa53fc 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDelegation/noDelegationToDefaultMethodInClass.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDelegation/noDelegationToDefaultMethodInClass.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: enable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/jvm8/kt11969.kt b/compiler/testData/codegen/box/jvm8/kt11969.kt index c8693e2a20a..5c60f8495dd 100644 --- a/compiler/testData/codegen/box/jvm8/kt11969.kt +++ b/compiler/testData/codegen/box/jvm8/kt11969.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 // WITH_RUNTIME +package test interface Z { private fun privateFun() = { "OK" } @@ -49,7 +50,7 @@ fun box(): String { val nested = Z.Nested::class.java val enclosingClass = nested.enclosingClass!! - if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}" + if (enclosingClass.name != "test.Z") return "fail 9: ${enclosingClass.name}" return "OK" } diff --git a/compiler/testData/codegen/box/jvm8/treeMapBridge.kt b/compiler/testData/codegen/box/jvm8/treeMapBridge.kt index 4dc738863b6..86a9a8dd7dd 100644 --- a/compiler/testData/codegen/box/jvm8/treeMapBridge.kt +++ b/compiler/testData/codegen/box/jvm8/treeMapBridge.kt @@ -1,6 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// java.lang.NoSuchMethodError: java.util.TreeMap.remove +// IGNORE_BACKEND: ANDROID + // FULL_JDK // JVM_TARGET: 1.8