All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java9.util.UnsafeAccess Maven / Gradle / Ivy

Go to download

Backport of Java 9 java.util.stream API for Android Studio 3+ desugar toolchain, forked from http://sourceforge.net/projects/streamsupport

There is a newer version: 1.7.4
Show newest version
/*
 * Written by Stefan Zobel and released to the
 * public domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
 */
package java9.util;

import java.lang.reflect.Field;

import sun.misc.Unsafe;

class UnsafeAccess {

    static final Unsafe unsafe;

    static {
        try {
            Field field = null;
            try {
                field = Unsafe.class.getDeclaredField("theUnsafe");
            } catch (NoSuchFieldException oldAndroid) {
                field = Unsafe.class.getDeclaredField("THE_ONE");
            }
            field.setAccessible(true);
            unsafe = (Unsafe) field.get(null);
        } catch (Exception e) {
            throw new Error(e);
        }
    }

    private UnsafeAccess() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy