Search in sources :

Example 36 with Unsafe

use of sun.misc.Unsafe in project voltdb by VoltDB.

the class UtilUnsafe method getUnsafe.

/** Fetch the Unsafe.  Use With Caution. */
public static Unsafe getUnsafe() {
    // Not on bootclasspath
    if (UtilUnsafe.class.getClassLoader() == null)
        return Unsafe.getUnsafe();
    try {
        final Field fld = Unsafe.class.getDeclaredField("theUnsafe");
        fld.setAccessible(true);
        return (Unsafe) fld.get(UtilUnsafe.class);
    } catch (Exception e) {
        throw new RuntimeException("Could not obtain access to sun.misc.Unsafe", e);
    }
}
Also used : Field(java.lang.reflect.Field) Unsafe(sun.misc.Unsafe)

Example 37 with Unsafe

use of sun.misc.Unsafe in project ignite by apache.

the class GridUnsafe method unsafe.

/**
 * @return Instance of Unsafe class.
 */
private static Unsafe unsafe() {
    try {
        return Unsafe.getUnsafe();
    } catch (SecurityException ignored) {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Unsafe>() {

                @Override
                public Unsafe run() throws Exception {
                    Field f = Unsafe.class.getDeclaredField("theUnsafe");
                    f.setAccessible(true);
                    return (Unsafe) f.get(null);
                }
            });
        } catch (PrivilegedActionException e) {
            throw new RuntimeException("Could not initialize intrinsics.", e.getCause());
        }
    }
}
Also used : Field(java.lang.reflect.Field) PrivilegedActionException(java.security.PrivilegedActionException) Unsafe(sun.misc.Unsafe) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction)

Example 38 with Unsafe

use of sun.misc.Unsafe in project algorithms by Iurii-Dziuban.

the class CrashStringTest method getUnsafe.

public static Unsafe getUnsafe() {
    try {
        Field field = Unsafe.class.getDeclaredField("theUnsafe");
        field.setAccessible(true);
        return (Unsafe) field.get(null);
    } catch (Exception ex) {
        throw new RuntimeException("can't get Unsafe instance", ex);
    }
}
Also used : Field(java.lang.reflect.Field) Unsafe(sun.misc.Unsafe)

Example 39 with Unsafe

use of sun.misc.Unsafe in project algorithms by Iurii-Dziuban.

the class NotValidAddressCrashTest method getUnsafe.

private static Unsafe getUnsafe() {
    try {
        Field field = Unsafe.class.getDeclaredField("theUnsafe");
        field.setAccessible(true);
        return (Unsafe) field.get(null);
    } catch (Exception ex) {
        throw new RuntimeException("can't get Unsafe instance", ex);
    }
}
Also used : Field(java.lang.reflect.Field) Unsafe(sun.misc.Unsafe)

Aggregations

Unsafe (sun.misc.Unsafe)39 Field (java.lang.reflect.Field)29 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)5 PrivilegedActionException (java.security.PrivilegedActionException)4 PrivilegedAction (java.security.PrivilegedAction)2 File (java.io.File)1 Options (org.rocksdb.Options)1 RocksDB (org.rocksdb.RocksDB)1 RocksIterator (org.rocksdb.RocksIterator)1 StringAppendOperator (org.rocksdb.StringAppendOperator)1 WriteOptions (org.rocksdb.WriteOptions)1