Skip to content Skip to sidebar Skip to footer

In Android, How To Invoke Sun.misc.unsafe Methods Using Java Reflection?

Although there are similar questions (such as A, B and C), their answers do not solve my problem. I am using Android Studio 1.5.1 targeting Android API 18 (before Android KitKat 4.

Solution 1:

Unfortunately sun.misc.Unsafe class not included in android standard library and you should use it between reflection but I found another solution: to use it between pre-compiled direct proxy class from my library: https://github.com/iamironz/unsafe

Solution 2:

This class will return you an Unsafe instance on almost all existing JVM implementations including Android (both VM versions): https://github.com/noctarius/tengi/blob/master/java/tengi-core/src/main/java/com/noctarius/tengi/core/impl/UnsafeUtil.java

Post a Comment for "In Android, How To Invoke Sun.misc.unsafe Methods Using Java Reflection?"