'Is it possible to access internal class with reflection in Kotlin?
Is it possible to access fields of internal class with reflection in Kotlin? I need to change the object of the third-party library's internal class.
Solution 1:[1]
You can use Suppress annotation in your class with following names: "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE" like this:
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
You can see an example here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-debug/src/DebugProbes.kt#L5
In this class, an internal object DebugProbesImpl is accessed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Viacheslav Rudyuk |