From 0d19b66c9696a19540b0449c8e28213f1215260c Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 10 Jun 2022 22:51:15 +0900 Subject: [PATCH] Fix DevSdkIgnoreRule target SDK annotation processing. The code added to DevSdkIgnoreRule to process the max target SDK annotations in aosp/2110064 was incorrect. It is trying to match the annotation name, but ::class.simpleName returns something like Proxy$3, not the actual name of the annotation. Use annotationClass.simpleName instead, which actually works. This was not caught in aosp/2110064 because it contained an even worse error which broke DevSdkIgnoreRule completely. That was fixed in aosp/2114653. Bug: 233553525 Test: LinkPropertiesTest#testExcludedRoutesDisabled passes on user build Change-Id: If9220e5ef00fafea556604b251b2106d15d063f8 --- .../devicetests/com/android/testutils/DevSdkIgnoreRule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt b/staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt index 6a073eae1f..3fcf801152 100644 --- a/staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt +++ b/staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRule.kt @@ -74,7 +74,7 @@ private fun isDevSdkUpTo(maxInclusive: Int): Boolean { private fun getMaxTargetSdk(description: Description): Int? { return description.annotations.firstNotNullOfOrNull { - MAX_TARGET_SDK_ANNOTATION_RE.matcher(it::class.simpleName).let { m -> + MAX_TARGET_SDK_ANNOTATION_RE.matcher(it.annotationClass.simpleName).let { m -> if (m.find()) m.group(1).toIntOrNull() else null } }