Browse Source

[resources] Delete Thread.currentThread().contextClassLoader on JVM targets (#4895)

The class loader retrieval method has been modified in both
`ResourceReader.android.kt` and `ResourceReader.desktop.kt` files. The
return statement has been changed to prioritize java class classLoader
and provides a clearer error message when it can't be found.

Fixes https://github.com/JetBrains/compose-multiplatform/issues/4887
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4742

## Release Notes
### Fixes - Resources
- Delete contextClassLoader usage on JVM targets
pull/4901/head
Konstantin 6 months ago committed by GitHub
parent
commit
c519a69d4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt
  2. 2
      components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt

2
components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt

@ -46,6 +46,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
} }
private fun getClassLoader(): ClassLoader { private fun getClassLoader(): ClassLoader {
return Thread.currentThread().contextClassLoader ?: this.javaClass.classLoader!! return this.javaClass.classLoader ?: error("Cannot find class loader")
} }
} }

2
components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt

@ -30,6 +30,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
} }
private fun getClassLoader(): ClassLoader { private fun getClassLoader(): ClassLoader {
return Thread.currentThread().contextClassLoader ?: this.javaClass.classLoader!! return this.javaClass.classLoader ?: error("Cannot find class loader")
} }
} }
Loading…
Cancel
Save