diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt index 668a9d8b116..c9216bc2404 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.android.tests import com.intellij.openapi.util.Ref -import org.jetbrains.kotlin.codegen.CodegenTestCase import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -47,18 +46,21 @@ internal fun patchFilesAndAddTest( val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_") val oldPackage = Ref() + val isJvmName = Ref(false) val isSingle = testFiles.size == 1 val resultFiles = testFiles.map { val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name TestClassInfo( fileName, - changePackage(newPackagePrefix, it.content, oldPackage), + changePackage(newPackagePrefix, it.content, oldPackage, isJvmName), oldPackage.get(), + isJvmName.get(), getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get()) ) } val packages = - resultFiles.map { OldPackageAndNew(it.oldPackage, it.newClassId.parent()) }.sortedByDescending { it.oldFqName.asString().length } + resultFiles.map { OldPackageAndNew(it.oldPackage, it.newPackagePartClassId.parent()) } + .sortedByDescending { it.oldFqName.asString().length } //If files contain any val or var declaration with same name as any package name // then use old conservative renaming scheme, otherwise use aggressive one @@ -95,7 +97,7 @@ internal fun patchFilesAndAddTest( /*replace all Class.forName*/ resultFiles.forEach { file -> file.content = resultFiles.fold(file.content) { r, param -> - patchClassForName(param.newClassId, param.oldPackage, r, conservativeRenameScheme) + patchClassForName(param.newPackagePartClassId, param.oldPackage, r, conservativeRenameScheme) } } @@ -104,6 +106,13 @@ internal fun patchFilesAndAddTest( file.content = file.content.patchSelfImports(file.newPackage) } + //patch root package parts usages in strings + resultFiles.forEach { file -> + file.content = resultFiles.fold(file.content) { r, param -> + patchRootPartNamesInStrings(param.newPackagePartClassId, param.oldPackage, param.isJvmName, r) + } + } + val boxFiles = resultFiles.filter { hasBoxMethod(it.content) } if (boxFiles.size != 1) { println("Several box methods in $testFile") @@ -111,22 +120,22 @@ internal fun patchFilesAndAddTest( filesHolder.addTest( resultFiles.filter { resultFile -> resultFile.name.endsWith(".kt") || resultFile.name.endsWith(".kts") }, - TestInfo("", boxFiles.last().newClassId, testFile) + TestInfo("", boxFiles.last().newPackagePartClassId, testFile) ) - return boxFiles.last().newClassId + return boxFiles.last().newPackagePartClassId } private fun hasBoxMethod(text: String): Boolean { return text.contains("fun box()") } -class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val newClassId: FqName) { - val newPackage = newClassId.parent() +class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val isJvmName: Boolean, val newPackagePartClassId: FqName) { + val newPackage = newPackagePartClassId.parent() } -private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref): String { +private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref, isJvmName: Ref): String { val matcher = packagePattern.matcher(text) if (matcher.find()) { val oldPackageName = matcher.toMatchResult().group(1) @@ -138,6 +147,7 @@ private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Re if (text.contains("@file:")) { val index = text.lastIndexOf("@file:") val packageDirectiveIndex = text.indexOf("\n", index) + isJvmName.set(true) return text.substring(0, packageDirectiveIndex + 1) + packageDirective + text.substring(packageDirectiveIndex + 1) } else { return packageDirective + text @@ -170,6 +180,19 @@ private fun patchClassForName(className: FqName, oldPackage: FqName, text: Strin ) } +private fun patchRootPartNamesInStrings( + className: FqName, + oldPackage: FqName, + isJvmName: Boolean, + text: String +): String { + if (!oldPackage.isRoot || isJvmName) return text + return text.replace( + ("\"" + oldPackage.child(className.shortName()).asString()).toRegex(), + "\"" + className.asString() + ) +} + private fun patchPackages(newPackage: FqName, oldPackage: FqName, text: String): String { if (oldPackage.isRoot) return text 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 5c13cc4b940..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 @@ -246,9 +246,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager } for (file in files) { - if (SpecialFiles.getExcludedFiles().contains(file.name)) { - continue - } if (file.isDirectory) { val listFiles = file.listFiles() if (listFiles != null) { @@ -261,7 +258,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager continue } - if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file)) { + if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file) || + InTextDirectivesUtils.isIgnoredTarget(TargetBackend.ANDROID, file) + ) { continue } @@ -313,16 +312,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager } private fun createTestFiles(file: File, expectedText: String): List = - TestFiles.createTestFiles( - file.name, - expectedText, - object : TestFiles.TestFileFactoryNoModules() { - override fun create(fileName: String, text: String, directives: Directives): KotlinBaseTest.TestFile { - return KotlinBaseTest.TestFile(fileName, text, directives) - } - }, false, - "kotlin.coroutines" - ) + CodegenTestCase.createTestFilesFromFile(file, expectedText, "kotlin.coroutines", false, TargetBackend.JVM) companion object { const val GRADLE_VERSION = "5.6.4" @@ -359,6 +349,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager val rootFolder = File("") val pathManager = PathManager(rootFolder.absolutePath, tmpFolder.absolutePath) generate(pathManager, true) + println("Android test project is generated into " + tmpFolder.absolutePath + " folder") } } } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java deleted file mode 100644 index 3487e1d339a..00000000000 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.android.tests; - -import java.util.HashSet; -import java.util.Set; - -public class SpecialFiles { - private static final Set excludedFiles = new HashSet<>(); - - static { - fillExcludedFiles(); - } - - public static Set getExcludedFiles() { - return excludedFiles; - } - - private static void fillExcludedFiles() { - // Reflection - excludedFiles.add("enclosing"); - excludedFiles.add("kt10259.kt"); - excludedFiles.add("simpleClassLiteral.kt"); - - //UnsatisfiedLinkError - excludedFiles.add("nativePropertyAccessors.kt"); - excludedFiles.add("topLevel.kt"); - - // "IOOBE: Invalid index 4, size is 4" for java.lang.reflect.ParameterizedType on Android - excludedFiles.add("innerGenericTypeArgument.kt"); - - // Cannot change package name - excludedFiles.add("kt6990.kt"); - excludedFiles.add("typeParameters.kt"); - excludedFiles.add("kt13133.kt"); - - // StackOverflow with StringBuilder (escape()) - excludedFiles.add("kt684.kt"); - - // Wrong enclosing info or signature after package renaming - excludedFiles.add("enclosingInfo"); - excludedFiles.add("signature"); - - // Some classes are not visible on android - excludedFiles.add("classpath.kt"); - - // Out of memory - excludedFiles.add("manyNumbers.kt"); - - // Native methods - excludedFiles.add("external"); - - // Additional nested class in 'Thread' class on Android - excludedFiles.add("nestedClasses.kt"); - - // KT-8120 - excludedFiles.add("closureOfInnerLocalClass.kt"); - excludedFiles.add("closureWithSelfInstantiation.kt"); - excludedFiles.add("quotedClassName.kt"); - - //wrong function resolution after package renaming - excludedFiles.add("apiVersionAtLeast1.kt"); - - //special symbols in names - excludedFiles.add("nameWithWhitespace.kt"); - - //some classes are moved from stdlib to compatibility package - excludedFiles.add("suspendFunction_1_2.kt"); - } - - private SpecialFiles() { - } -} diff --git a/compiler/testData/codegen/box/classes/quotedClassName.kt b/compiler/testData/codegen/box/classes/quotedClassName.kt index 0c6a90ac5d3..9882cda72bb 100644 --- a/compiler/testData/codegen/box/classes/quotedClassName.kt +++ b/compiler/testData/codegen/box/classes/quotedClassName.kt @@ -5,6 +5,7 @@ // Therefore, do not attemp to dex this file as it will fail. // See: https://source.android.com/devices/tech/dalvik/dex-format#simplename // IGNORE_DEXING +// IGNORE_BACKEND: ANDROID class `A!u00A0`() { val ok = "OK" diff --git a/compiler/testData/codegen/box/external/jvmStaticExternal.kt b/compiler/testData/codegen/box/external/jvmStaticExternal.kt index 22ac836a18a..e3daa4a5f7a 100644 --- a/compiler/testData/codegen/box/external/jvmStaticExternal.kt +++ b/compiler/testData/codegen/box/external/jvmStaticExternal.kt @@ -1,5 +1,6 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/external/jvmStaticExternalPrivate.kt b/compiler/testData/codegen/box/external/jvmStaticExternalPrivate.kt index 7d2e3346ba3..58f8dd2d9bd 100644 --- a/compiler/testData/codegen/box/external/jvmStaticExternalPrivate.kt +++ b/compiler/testData/codegen/box/external/jvmStaticExternalPrivate.kt @@ -1,5 +1,6 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/external/withDefaultArg.kt b/compiler/testData/codegen/box/external/withDefaultArg.kt index d4b27538e96..e806d8a624a 100644 --- a/compiler/testData/codegen/box/external/withDefaultArg.kt +++ b/compiler/testData/codegen/box/external/withDefaultArg.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/box/fullJdk/native/nativePropertyAccessors.kt b/compiler/testData/codegen/box/fullJdk/native/nativePropertyAccessors.kt index 9c7c1b67050..3892e060b42 100644 --- a/compiler/testData/codegen/box/fullJdk/native/nativePropertyAccessors.kt +++ b/compiler/testData/codegen/box/fullJdk/native/nativePropertyAccessors.kt @@ -1,5 +1,6 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // FULL_JDK diff --git a/compiler/testData/codegen/box/fullJdk/native/simpleNative.kt b/compiler/testData/codegen/box/fullJdk/native/simpleNative.kt index 3675e1fa6d6..af49fef30c5 100644 --- a/compiler/testData/codegen/box/fullJdk/native/simpleNative.kt +++ b/compiler/testData/codegen/box/fullJdk/native/simpleNative.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // FULL_JDK diff --git a/compiler/testData/codegen/box/fullJdk/native/topLevel.kt b/compiler/testData/codegen/box/fullJdk/native/topLevel.kt index ef215d03b29..8ca5223ada7 100644 --- a/compiler/testData/codegen/box/fullJdk/native/topLevel.kt +++ b/compiler/testData/codegen/box/fullJdk/native/topLevel.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID // FULL_JDK diff --git a/compiler/testData/codegen/box/hashPMap/manyNumbers.kt b/compiler/testData/codegen/box/hashPMap/manyNumbers.kt index 71146219ca5..36fa247c967 100644 --- a/compiler/testData/codegen/box/hashPMap/manyNumbers.kt +++ b/compiler/testData/codegen/box/hashPMap/manyNumbers.kt @@ -1,5 +1,8 @@ // TARGET_BACKEND: JVM +// Out of memory on Android 4.4 +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT import java.util.* diff --git a/compiler/testData/codegen/box/localClasses/nameWithWhitespace.kt b/compiler/testData/codegen/box/localClasses/nameWithWhitespace.kt index a51545f53d9..f6a405d2409 100644 --- a/compiler/testData/codegen/box/localClasses/nameWithWhitespace.kt +++ b/compiler/testData/codegen/box/localClasses/nameWithWhitespace.kt @@ -8,6 +8,7 @@ // // See: https://source.android.com/devices/tech/dalvik/dex-format#simplename // IGNORE_DEXING +// IGNORE_BACKEND: ANDROID fun `method with spaces`(): String { data class C(val s: String = "OK") diff --git a/compiler/testData/codegen/box/oldLanguageVersions/coroutines/featureIntersection/suspendFunction_1_2.kt b/compiler/testData/codegen/box/oldLanguageVersions/coroutines/featureIntersection/suspendFunction_1_2.kt index 46649994e80..761605bb183 100644 --- a/compiler/testData/codegen/box/oldLanguageVersions/coroutines/featureIntersection/suspendFunction_1_2.kt +++ b/compiler/testData/codegen/box/oldLanguageVersions/coroutines/featureIntersection/suspendFunction_1_2.kt @@ -4,6 +4,9 @@ // WITH_RUNTIME // WITH_COROUTINES +// some classes are moved from stdlib to compatibility package +// IGNORE_BACKEND: ANDROID + import helpers.* import kotlin.coroutines.* diff --git a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt index 1b91be8d2d8..bef742f55d8 100644 --- a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt +++ b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt @@ -1,5 +1,8 @@ // TARGET_BACKEND: JVM +// l[0] === 1000 is true on Android +// IGNORE_BACKEND: ANDROID + fun box(): String { val l = java.util.ArrayList() l.add(1000) diff --git a/compiler/testData/codegen/box/primitiveTypes/kt684.kt b/compiler/testData/codegen/box/primitiveTypes/kt684.kt index 34be34ea676..7b603b5ecdf 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt684.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt684.kt @@ -2,6 +2,9 @@ // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE +// StackOverflow with StringBuilder (escape()) on Android 4.4 +// IGNORE_BACKEND: ANDROID + fun escapeChar(c : Char) : String? = when (c) { '\\' -> "\\\\" '\n' -> "\\n" diff --git a/compiler/testData/codegen/box/reflection/annotations/setparam.kt b/compiler/testData/codegen/box/reflection/annotations/setparam.kt index b11ad499f20..c6ebd08c5bb 100644 --- a/compiler/testData/codegen/box/reflection/annotations/setparam.kt +++ b/compiler/testData/codegen/box/reflection/annotations/setparam.kt @@ -2,6 +2,9 @@ // WITH_REFLECT // IGNORE_BACKEND: JS_IR, JS, NATIVE +// different annotation order +// IGNORE_BACKEND: ANDROID + package test import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/reflection/classLiterals/simpleClassLiteral.kt b/compiler/testData/codegen/box/reflection/classLiterals/simpleClassLiteral.kt index 966c774df65..a60befb6003 100644 --- a/compiler/testData/codegen/box/reflection/classLiterals/simpleClassLiteral.kt +++ b/compiler/testData/codegen/box/reflection/classLiterals/simpleClassLiteral.kt @@ -1,9 +1,10 @@ // IGNORE_BACKEND: NATIVE // WITH_REFLECT +package test class A fun box(): String { val klass = A::class - return if (klass.toString() == "class A") "OK" else "Fail: $klass" + return if (klass.toString() == "class test.A") "OK" else "Fail: $klass" } diff --git a/compiler/testData/codegen/box/reflection/enclosing/functionExpressionInProperty.kt b/compiler/testData/codegen/box/reflection/enclosing/functionExpressionInProperty.kt index 9d8f92903af..a15a567d50d 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/functionExpressionInProperty.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/functionExpressionInProperty.kt @@ -1,5 +1,8 @@ // TARGET_BACKEND: JVM +// has declaring class on Android 4.4 +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT val property = fun () {} diff --git a/compiler/testData/codegen/box/reflection/enclosing/kt11969.kt b/compiler/testData/codegen/box/reflection/enclosing/kt11969.kt index 583d31e11f3..954a61f1c88 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/kt11969.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/kt11969.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // TARGET_BACKEND: JVM +package test interface Z { private fun privateFun() = { "OK" } @@ -58,7 +59,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/reflection/enclosing/kt6691_lambdaInSamConstructor.kt b/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt index 42814930c65..aff2a36db18 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test var lambda = {} @@ -20,7 +21,7 @@ fun box(): String { if (enclosingMethod?.getName() != "run") return "method: $enclosingMethod" val enclosingClass = javaClass.getEnclosingClass()!!.getName() - if (enclosingClass != "A\$prop\$1") return "enclosing class: $enclosingClass" + if (enclosingClass != "test.A\$prop\$1") return "enclosing class: $enclosingClass" val declaringClass = javaClass.getDeclaringClass() if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInClassObject.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInClassObject.kt index fb95e90b88b..454c4fe2077 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInClassObject.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInClassObject.kt @@ -1,7 +1,9 @@ // TARGET_BACKEND: JVM -// WITH_REFLECT +// has declaring class on Android 4.4 +// IGNORE_BACKEND: ANDROID +// WITH_REFLECT class O { companion object { // Currently we consider in class O as the enclosing method of this lambda, diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInConstructor.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInConstructor.kt index e952222a76a..d358b73f6ea 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInConstructor.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInConstructor.kt @@ -1,6 +1,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test class C { val l: Any = {} @@ -9,10 +10,10 @@ class C { fun box(): String { val javaClass = C().l.javaClass val enclosingConstructor = javaClass.getEnclosingConstructor() - if (enclosingConstructor?.getDeclaringClass()?.getName() != "C") return "ctor: $enclosingConstructor" + if (enclosingConstructor?.getDeclaringClass()?.getName() != "test.C") return "ctor: $enclosingConstructor" val enclosingClass = javaClass.getEnclosingClass() - if (enclosingClass?.getName() != "C") return "enclosing class: $enclosingClass" + if (enclosingClass?.getName() != "test.C") return "enclosing class: $enclosingClass" val declaringClass = javaClass.getDeclaringClass() if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInMemberFunction.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInMemberFunction.kt index 78281274643..c3d6a61290c 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInMemberFunction.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInMemberFunction.kt @@ -1,6 +1,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test class C { fun foo(): Any { @@ -15,7 +16,7 @@ fun box(): String { if (enclosingMethod?.getName() != "foo") return "method: $enclosingMethod" val enclosingClass = javaClass.getEnclosingClass() - if (enclosingClass?.getName() != "C") return "enclosing class: $enclosingClass" + if (enclosingClass?.getName() != "test.C") return "enclosing class: $enclosingClass" val declaringClass = javaClass.getDeclaringClass() if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInObjectDeclaration.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInObjectDeclaration.kt index 0e3f71c0fb6..fe30549af0d 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInObjectDeclaration.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInObjectDeclaration.kt @@ -1,5 +1,8 @@ // TARGET_BACKEND: JVM +// has declaring class on Android 4.4 +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT object O { diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInPackage.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInPackage.kt index 8f9b44166c0..a09037ad1a3 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInPackage.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInPackage.kt @@ -1,5 +1,8 @@ // TARGET_BACKEND: JVM +// has declaring class on Android 4.4 +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT val l: Any = {} diff --git a/compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyDelegate.kt b/compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyDelegate.kt index bb87f24898b..4080a474475 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyDelegate.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/lambdaInPropertyDelegate.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +package test class C { val f by foo { @@ -19,7 +20,7 @@ fun box(): String { if (emInner?.getName() != "invoke") return "Fail: incorrect enclosing method for inner lambda: $emInner" val ecInner = innerLambda.getEnclosingClass() - if (ecInner?.getName() != "C\$f\$2") return "Fail: incorrect enclosing class for inner lambda: $ecInner" + if (ecInner?.getName() != "test.C\$f\$2") return "Fail: incorrect enclosing class for inner lambda: $ecInner" val ectorInner = innerLambda.getEnclosingConstructor() if (ectorInner != null) return "Fail: inner lambda should not have enclosing constructor: $ectorInner" @@ -35,7 +36,7 @@ fun box(): String { if (emOuter != null) return "Fail: outer lambda should not have enclosing method: $emOuter" val ecOuter = outerLambda.getEnclosingClass() - if (ecOuter?.getName() != "C") return "Fail: incorrect enclosing class for outer lambda: $ecOuter" + if (ecOuter?.getName() != "test.C") return "Fail: incorrect enclosing class for outer lambda: $ecOuter" val ectorOuter = outerLambda.getEnclosingConstructor() if (ectorOuter == null) return "Fail: outer lambda _should_ have enclosing constructor" diff --git a/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt b/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt index 0293492d0ab..e90a186ca37 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt @@ -1,6 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// "IOOBE: Invalid index 4, size is 4" for java.lang.reflect.ParameterizedType on Android +// IGNORE_BACKEND: ANDROID + // WITH_REFLECT import kotlin.reflect.jvm.javaType diff --git a/compiler/testData/codegen/box/traits/defaultImplCall.kt b/compiler/testData/codegen/box/traits/defaultImplCall.kt index 03fb86a3fcf..6b0eed7c16a 100644 --- a/compiler/testData/codegen/box/traits/defaultImplCall.kt +++ b/compiler/testData/codegen/box/traits/defaultImplCall.kt @@ -1,6 +1,10 @@ // !JVM_DEFAULT_MODE: disable // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM + +// First item on Android is `java.lang.Thread.getStackTrace` +// IGNORE_BACKEND: ANDROID + // WITH_RUNTIME // FULL_JDK diff --git a/compiler/testData/codegen/boxInline/bytecodePreprocessing/apiVersionAtLeast1.kt b/compiler/testData/codegen/boxInline/bytecodePreprocessing/apiVersionAtLeast1.kt index b5364190bb1..b7c6ea35ca0 100644 --- a/compiler/testData/codegen/boxInline/bytecodePreprocessing/apiVersionAtLeast1.kt +++ b/compiler/testData/codegen/boxInline/bytecodePreprocessing/apiVersionAtLeast1.kt @@ -1,4 +1,8 @@ // TARGET_BACKEND: JVM + +// Wrong function resolution after package renaming +// IGNORE_BACKEND: ANDROID + // FILE: 1.kt package kotlin.internal diff --git a/compiler/testData/codegen/boxInline/reified/kt6990.kt b/compiler/testData/codegen/boxInline/reified/kt6990.kt index b6bb3de3f8d..c3f4f9ea17f 100644 --- a/compiler/testData/codegen/boxInline/reified/kt6990.kt +++ b/compiler/testData/codegen/boxInline/reified/kt6990.kt @@ -1,4 +1,6 @@ // TARGET_BACKEND: JVM +// IGNORE_BACKEND: ANDROID + // FILE: 1.kt // WITH_REFLECT package test diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index 5f68e5dc33a..d5ba883d77a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -773,16 +773,27 @@ public abstract class CodegenTestCase extends KotlinBaseTest createTestFilesFromFile(File file, @NotNull String expectedText) { + protected List createTestFilesFromFile(@NotNull File file, @NotNull String expectedText) { + return createTestFilesFromFile(file, expectedText, coroutinesPackage, parseDirectivesPerFiles(), getBackend()); + } + + @NotNull + public static List createTestFilesFromFile( + @NotNull File file, + @NotNull String expectedText, + @NotNull String coroutinesPackage, + boolean parseDirectivesPerFiles, + @NotNull TargetBackend backend + ) { List testFiles = TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactoryNoModules() { @NotNull @Override public TestFile create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives) { return new TestFile(fileName, text, directives); } - }, false, coroutinesPackage, parseDirectivesPerFiles()); + }, false, coroutinesPackage, parseDirectivesPerFiles); if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "WITH_HELPERS")) { - testFiles.add(new TestFile("CodegenTestHelpers.kt", TestHelperGeneratorKt.createTextForCodegenTestHelpers(getBackend()))); + testFiles.add(new TestFile("CodegenTestHelpers.kt", TestHelperGeneratorKt.createTextForCodegenTestHelpers(backend))); } return testFiles; } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt index b07eb77b20b..851f6aaf8d7 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt @@ -15,7 +15,8 @@ enum class TargetBackend( JVM_IR(true, JVM), JS(false), JS_IR(true, JS), - WASM(true); + WASM(true), + ANDROID(false, JVM); val compatibleWith get() = compatibleWithTargetBackend ?: ANY }