From cee9bf702b67268555aedafbae6755a1520002f3 Mon Sep 17 00:00:00 2001 From: Mohammad Ehsan Mohit Date: Mon, 11 Nov 2024 06:43:05 +0330 Subject: [PATCH] =?UTF-8?q?Replace=20"java.util.Optional"=20String=20with?= =?UTF-8?q?=20`class.java.name`=20to=20prevent=E2=80=A6=20(#89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replace "java.util.Optional" String with `class.java.name` to prevent conflicts when desugaring Set `enable`. * Increase Jfrog builder version from 4.11.0 to 4.23.4 --------- Co-authored-by: Ehsan Mohit --- buildSrc/src/main/kotlin/deps.kt | 2 +- .../java/com/gojek/courier/utils/RuntimePlatform.kt | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/deps.kt b/buildSrc/src/main/kotlin/deps.kt index 9df35a12..08bde1e2 100644 --- a/buildSrc/src/main/kotlin/deps.kt +++ b/buildSrc/src/main/kotlin/deps.kt @@ -134,4 +134,4 @@ object deps { const val runtime = "androidx.work:work-runtime:${versions.workManager}" const val runtime_2_6_0 = "androidx.work:work-runtime:2.6.0" } -} \ No newline at end of file +} diff --git a/courier/src/main/java/com/gojek/courier/utils/RuntimePlatform.kt b/courier/src/main/java/com/gojek/courier/utils/RuntimePlatform.kt index f6b5e019..e9a59c34 100644 --- a/courier/src/main/java/com/gojek/courier/utils/RuntimePlatform.kt +++ b/courier/src/main/java/com/gojek/courier/utils/RuntimePlatform.kt @@ -1,7 +1,10 @@ package com.gojek.courier.utils +import android.os.Build.VERSION +import android.os.Build.VERSION_CODES import java.lang.invoke.MethodHandles.Lookup import java.lang.reflect.Method +import java.util.Optional internal sealed class RuntimePlatform { @@ -43,8 +46,12 @@ internal sealed class RuntimePlatform { fun get(): RuntimePlatform = PLATFORM private fun findPlatform(): RuntimePlatform = try { - Class.forName("java.util.Optional") - Java8() + if (VERSION.SDK_INT >= VERSION_CODES.N) { + Class.forName(Optional::class.java.name) + Java8() + } else { + Default() + } } catch (ignored: ClassNotFoundException) { Default() }