Skip to content

Commit

Permalink
Replace "java.util.Optional" String with class.java.name to prevent… (
Browse files Browse the repository at this point in the history
#89)

* 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 <[email protected]>
  • Loading branch information
MohammadEhsanMohit and Ehsan Mohit authored Nov 11, 2024
1 parent 18ab014 commit cee9bf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
11 changes: 9 additions & 2 deletions courier/src/main/java/com/gojek/courier/utils/RuntimePlatform.kt
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit cee9bf7

Please sign in to comment.