Home United States USA — software Bypassing Kotlin's Null-Safety

Bypassing Kotlin's Null-Safety

219
0
SHARE

Find out when and how to bypass null-safety in Kotlin with Reflection and the Unsafe class, including tips for working with external libraries.
This class is like one of those scary computer game creatures that are there only to intimidate us. In theory, we can’t get close because they are part of the environment, but it’s often possible by exploiting glitches or holes.
And this allows us, indeed, to effectively bypass Kotlin’s safety checks:
If we start using it in Kotlin, we indeed might end up with an undesired behavior observed above:
In this case, we simply need to perform checks manually after instantiation, which is not super problematic — what’s problematic is the lack of consciousness that this happens, which can cost much.
Are you sure the library you are using is not doing that internally?
Code snippets can be found on GitHub.

Continue reading...