Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android中的sun.misc.Unsafe替代方案_Java_Android - Fatal编程技术网

Java Android中的sun.misc.Unsafe替代方案

Java Android中的sun.misc.Unsafe替代方案,java,android,Java,Android,我知道,sun.misc.Unsafe(据我所知,这是可以使用的)只在Android上部分实现(该死),但我正在Android上移植,有很多类似的指令: private static sun.misc.Unsafe getUnsafe() { try { Field unsafeField = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); unsafeField.setAccessible(tru

我知道,
sun.misc.Unsafe
(据我所知,这是可以使用的)只在Android上部分实现(该死),但我正在Android上移植,有很多类似的指令:

private static sun.misc.Unsafe getUnsafe() {
    try {
        Field unsafeField = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
        unsafeField.setAccessible(true);
        return (sun.misc.Unsafe) unsafeField.get(null);
    } catch (SecurityException e) {
        throw new RuntimeException("Could not access the sun.misc.Unsafe handle, permission denied by security manager.", e);
    } catch (NoSuchFieldException e) {
        throw new RuntimeException("The static handle field in sun.misc.Unsafe was not found.");
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("Bug: Illegal argument reflection access for static field.", e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Access to sun.misc.Unsafe is forbidden by the runtime.", e);
    } catch (Throwable t) {
        throw new RuntimeException("Unclassified error while trying to access the sun.misc.Unsafe handle.", t);
    }
}
在编译时生成错误

所以我的问题是:在安卓系统上有没有其他类似的替代方案